这代码哪里出错了!

chinagdzhao 2015-01-31 03:46:11
想在启动界面显示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
...全文
759 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouhui222 2017-07-05
  • 打赏
  • 举报
回复
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
三楼の郎 2015-02-07
  • 打赏
  • 举报
回复
Check1.Value = 1
chinagdzhao 2015-02-06
  • 打赏
  • 举报
回复
引用 5 楼 of123 的回复:
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
最后这里提示错 ,Check1.Value = True 生成工程后提示 Run-time error '380': Invalid property value
of123 2015-02-02
  • 打赏
  • 举报
回复
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
楚狂歌 2015-02-01
  • 打赏
  • 举报
回复
Check1.Value = True不会触发click事件吧?我记得VB.net是不触发的 应该是valuechanged事件
无·法 2015-01-31
  • 打赏
  • 举报
回复
你这代码有问题吧。 明显的缺少了几个逗号,怎么可能运行得起来呢。 你可以一步步调试,在获取值那边加入个msgbox检查下变量。 看看到底是到哪一行代码和你期望的有差异。 如果光要个结果花钱找人写代码好了。
chinagdzhao 2015-01-31
  • 打赏
  • 举报
回复
引用 1 楼 lkmiawivw 的回复:
1、在操作时自动将当前勾选的状态保存到一个文件中 2、在下次加载窗体时读取这个文件,根据这个文件存储的上一次操作情况自动勾选。
我就是先保存着ini文件,然后加载的时候读取,可是勾选退出再打开以后。。勾选项还是没选上
lkmiawivw 2015-01-31
  • 打赏
  • 举报
回复
1、在操作时自动将当前勾选的状态保存到一个文件中 2、在下次加载窗体时读取这个文件,根据这个文件存储的上一次操作情况自动勾选。

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧