VB的LISTBOX保存到INI问题
新手,没有好的办法,保存的时候是这样的:DimstrIniFileNameAsStringstrIniFileName=App.Path&"\mirsoft.in...
新手,没有好的办法,保存的时候是这样的:Dim strIniFileName As StringstrIniFileName = App.Path & "\mirsoft.ini"Call WriteIniFile(strIniFileName, "自定义文本", "文本0", List1.List(0))Call WriteIniFile(strIniFileName, "自定义文本", "文本1", List1.List(1))Call WriteIniFile(strIniFileName, "自定义文本", "文本2", List1.List(2))Call WriteIniFile(strIniFileName, "自定义文本", "文本3", List1.List(3))Call WriteIniFile(strIniFileName, "自定义文本", "文本4", List1.List(4))Call WriteIniFile(strIniFileName, "自定义文本", "文本5", List1.List(5))程序打开读取是这样来的:Dim strIniFileName As StringstrIniFileName = App.Path & "\mirsoft.ini"List1.List(0) = ReadIniFile(strIniFileName, "自定义文本", "文本0")List1.List(1) = ReadIniFile(strIniFileName, "自定义文本", "文本1")List1.List(2) = ReadIniFile(strIniFileName, "自定义文本", "文本2")List1.List(3) = ReadIniFile(strIniFileName, "自定义文本", "文本3")List1.List(4) = ReadIniFile(strIniFileName, "自定义文本", "文本4")List1.List(5) = ReadIniFile(strIniFileName, "自定义文本", "文本5")用这样的傻办法倒也可以存读了,但是如果里面的行数超过了6个,他就不会保存了。还有个问题,比如里面现在是2行数据,那保存的情况下正常,读取的时候下面多余的那几行就把空格写道LISTBOX里了。这样程序一工作就出错了,有更好的办法吗!
展开
1个回答
展开全部
Private Sub Command1_Click()
Dim strIniFileName As String
strIniFileName = App.Path & "\mirsoft.ini"
Dim i As Integer, j As Integer
i = List1.ListCount '取得列表框中数据的行数
For j = 0 To i - 1
Call WriteIniFile(strIniFileName, "自定义文本", "文本0", List1.List(j))
Next
'程序打开读取是这样来的:
Dim strIniFileName As String
strIniFileName = App.Path & "\mirsoft.ini"
i = List1.ListCount '取得列表框中数据的行数
For j = 0 To i - 1
List1.List(j) = ReadIniFile(strIniFileName, "自定义文本", "文本" & j)
Next
End Sub
张志晨
Dim strIniFileName As String
strIniFileName = App.Path & "\mirsoft.ini"
Dim i As Integer, j As Integer
i = List1.ListCount '取得列表框中数据的行数
For j = 0 To i - 1
Call WriteIniFile(strIniFileName, "自定义文本", "文本0", List1.List(j))
Next
'程序打开读取是这样来的:
Dim strIniFileName As String
strIniFileName = App.Path & "\mirsoft.ini"
i = List1.ListCount '取得列表框中数据的行数
For j = 0 To i - 1
List1.List(j) = ReadIniFile(strIniFileName, "自定义文本", "文本" & j)
Next
End Sub
张志晨
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询