【android通讯软件源码】【语音识别 数字 源码】【神武呱呱助手源码】vb listview 源码

时间:2024-12-29 01:13:49 来源:资讯论坛app源码 编辑:股票指标翻译源码查询

1.VB的Listview保存读取

vb listview 源码

VB的Listview保存读取

       å®Œæ•´ä»£ç æ³¨ï¼šListview定义了4个列,源码android通讯软件源码自己需要几列改下就好Option Explicit

       '读写INI文件

       Private Declare Function GetPrivateProfileString Lib "kernel" 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 Declare Function WritePrivateProfileString Lib "kernel" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As LongPrivate Sub Form_Load()

        Randomize

       End SubPrivate Sub 随机值_Click()

        Dim i As Integer, j As Integer, lv As ListItem

        ListView1.ListItems.Clear

        For i = 0 To

        Set lv = ListView1.ListItems.Add(, , i + 1)

        For j = 0 To 2

        lv.ListSubItems.Add , , CInt(Rnd * )

        Next j

        Next i

       End SubPrivate Sub 保存_Click()

        Dim si As Integer, sj As Integer, tmpstr As String

        If ListView1.ListItems.Count = 0 Then MsgBox "没有可保存的内容", vbInformation, "提示": Exit Sub

        tmpstr = ListView1.ListItems.Count

        WritePrivateProfileString "统计项", "总行数", tmpstr, App.Path & "\ABC.ini"

        tmpstr = ListView1.ListItems(1).ListSubItems.Count

        WritePrivateProfileString "统计项", "总列数", tmpstr, App.Path & "\ABC.ini"

        With ListView1.ListItems

        For si = 1 To .Count

        WritePrivateProfileString "第" & si & "行", "第1列", .Item(si).Text, App.Path & "\ABC.ini"

        For sj = 1 To .Item(si).ListSubItems.Count

        WritePrivateProfileString "第" & si & "行", "第" & sj + 1 & "列", .Item(si).SubItems(sj), App.Path & "\ABC.ini"

        Next sj

        Next si

        End With

        MsgBox "保存成功!", vbInformation, "提示"

       End SubPrivate Sub 读取_Click()

        Dim sr As Integer, sc As Integer, li As Integer, lj As Integer, tmptxt As String, lvs As ListItem

        tmptxt = Space$()

        GetPrivateProfileString "统计项", "总行数", "0", tmptxt, , App.Path & "\ABC.ini"

        sr = CInt(tmptxt) '总行数

        tmptxt = Space$()

        GetPrivateProfileString "统计项", "总行数", "0", tmptxt, , App.Path & "\ABC.ini"

        sc = CInt(tmptxt)

        If sr = 0 Then

        MsgBox "总行数为零哦"

        Exit Sub

        Else

        ListView1.ListItems.Clear

        End If

        For li = 1 To sr

        For lj = 1 To sc '这里你的列表

        tmptxt = Space$()

        GetPrivateProfileString "第" & li & "行", "第" & lj & "列", "", tmptxt, , App.Path & "\ABC.ini"

        If lj = 1 Then

        Set lvs = ListView1.ListItems.Add(, , tmptxt)

        Else

        lvs.ListSubItems.Add , , tmptxt

        End If

        Next lj

        Next li

       End Sub

copyright © 2016 powered by 皮皮网   sitemap