想在啟動界面顯示checkbox的上一次勾選
Private Sub Check1_Click()
If Ceck1.Value = 0 Then
Dim success As Long
success = WritePrivateProfileString("AA", "BB", "0", App.Path & "\Config.ini")
Else
Dim successa As Long
successa = WritePrivateProfileString("AA "BB "1", App.Path & "\Config.ini")
Check1.Value = 1
End 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 & "\Config.ini")
if buff = 1 Then
Check1.Value = True
End If
End sub
uj5u.com熱心網友回復:
1、在操作時自動將當前勾選的狀態保存到一個檔案中2、在下次加載表單時讀取這個檔案,根據這個檔案存盤的上一次操作情況自動勾選。
uj5u.com熱心網友回復:
我就是先保存著ini檔案,然后加載的時候讀取,可是勾選退出再打開以后。。勾選項還是沒選上
uj5u.com熱心網友回復:
你這代碼有問題吧。 明顯的缺少了幾個逗號,怎么可能運行得起來呢。你可以一步步除錯,在獲取值那邊加入個msgbox檢查下變數。 看看到底是到哪一行代碼和你期望的有差異。 如果光要個結果花錢找人寫代碼好了。
uj5u.com熱心網友回復:
Check1.Value = True不會觸發click事件吧?我記得VB.net是不觸發的應該是valuechanged事件
uj5u.com熱心網友回復:
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 = 0 Then
success = WritePrivateProfileString("AA", "BB", "0", App.Path & "\Config.ini")
Else
success = WritePrivateProfileString("AA", "BB", "1", App.Path & "\Config.ini")
End 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.Path & "\Config.ini")
If Left(buff, 1) = "1" Then Check1.Value = True
End sub
uj5u.com熱心網友回復:
最后這里提示錯 ,Check1.Value = True
生成工程后提示
Run-time error '380':
Invalid property value
uj5u.com熱心網友回復:
Check1.Value = 1uj5u.com熱心網友回復:
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.Path & "\Config.ini")
End Sub
Private Sub Form_Load()
Dim sBuffer As String * 255,
GetPrivateProfileString "AA", "BB", vbNullString, sBuffer, Len(sBuffer), filename
Ceck1.Value = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
End sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/55833.html
標籤:控件
