Home > Software engineering >  This code where wrong!
This code where wrong!

Time:09-20

want to start the interface shows the last check the checkbox


 Private Sub Check1_Click () 
If Ceck1. Value=https://bbs.csdn.net/topics/0 Then
Dim success As Long
Success=WritePrivateProfileString (" AA ", "BB", "0", the App. The Path & amp; "\ Config ini")
The Else
Dim successa As Long
Successa=WritePrivateProfileString (" AA "BB" 1 ", the App. The Path & amp; "\ Config ini")
Check1. Value=https://bbs.csdn.net/topics/1
End the If
End Sub



Private Sub Form_Load ()
Dim ret As Long
Dim buff As String
Buff=String (255, 0)
Ret=GetPrivateProfileString (" AA "BB" BB buff, 256, App. Path & amp; "\ Config ini")
If buff=1 Then
Check1. Value=https://bbs.csdn.net/topics/True
End the If
End sub

CodePudding user response:

1, when the operation automatically save the current state of the check to a file
2, when the load form next time to read this file, according to the last time the file storage operation situation automatic check,

CodePudding user response:

reference 1st floor lkmiawivw response:
1, when operating automatically save the current state of the check to a file
2, when the load form next time to read this file, according to the last time the file storage operation situation automatic check,


I just kept the ini file first, then read when loading, but checked out after open, again, check the item or not

CodePudding user response:

The code you have any question, apparent lack of a few commas, how can run it up,

You can debug step by step, on the other side get the value to join a msgbox examine variables, and see where exactly one line of code and you expect there are differences, if light for a result pay someone to write code,

CodePudding user response:

Check1. Value=https://bbs.csdn.net/topics/True will not trigger the click event? I remember that VB.net is not trigger

Should be a valuechanged event

CodePudding user response:

 Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long 
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Private Sub Check1_Click ()
Dim success As Long
If Ceck1. Value=https://bbs.csdn.net/topics/0 Then
Success=WritePrivateProfileString (" AA ", "BB", "0", the App. The Path & amp; "\ Config ini")
The Else
Success=WritePrivateProfileString (" AA ", "BB", "1", the App. The Path & amp; "\ Config ini")
End the If
End Sub

Private Sub Form_Load ()
Dim ret As Long
Dim buff As String
Buff=String (255, 0)
Ret=GetPrivateProfileString (" AA ", "BB", "0", buff, 256, App. The Path & amp; "\ Config ini")
If Left (buff, 1)="1" Then Check1. Value=https://bbs.csdn.net/topics/True
End sub

CodePudding user response:

The
reference 5 floor of123 response:
 Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long 
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Private Sub Check1_Click ()
Dim success As Long
If Ceck1. Value=https://bbs.csdn.net/topics/0 Then
Success=WritePrivateProfileString (" AA ", "BB", "0", the App. The Path & amp; "\ Config ini")
The Else
Success=WritePrivateProfileString (" AA ", "BB", "1", the App. The Path & amp; "\ Config ini")
End the If
End Sub

Private Sub Form_Load ()
Dim ret As Long
Dim buff As String
Buff=String (255, 0)
Ret=GetPrivateProfileString (" AA ", "BB", "0", buff, 256, App. The Path & amp; "\ Config ini")
If Left (buff, 1)="1" Then Check1. Value=https://bbs.csdn.net/topics/True
End sub


The last hint wrong here, Check1. Value=https://bbs.csdn.net/topics/True
Generate engineering after prompt
The Run - time error '380' :
Invalid property value

CodePudding user response:

Check1. Value=https://bbs.csdn.net/topics/1

CodePudding user response:

 Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long 
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long


Private Sub Check1_Click ()
WritePrivateProfileString (" AA ", "BB", Ceck1 Value, App. The Path & amp; "\ Config ini")
End Sub

Private Sub Form_Load ()
Dim sBuffer As String * 255,
nullnullnull
  • Related