看板 Visual_Basic 關於我們 聯絡資訊
寫了一種不是很有效率捉取ini下,所有section的處理方式 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click sSection = vbNullString sKey = vbNullString sinifilename = Application.StartupPath & "\ERPTOP.ini" If Not FileExistOrNot(sinifilename) Then Exit Sub Dim tempStr As String Dim StrList = New Collection Dim exitFor As Integer exitFor = 0 sKeyValue = Space(65536) lReturnLen = GetPrivateProfileString(sSection, _ sKey, "", sKeyValue, 32768, sinifilename) tempStr = "" For i = 0 To 65536 '連續2次值為nothing代表已讀完最後一個section If (exitFor = 1) And _ (sKeyValue.ToCharArray()(i) = Nothing) Then MsgBox(i) Exit For Else exitFor = 0 End If If (sKeyValue.ToCharArray()(i) <> "") And _ (sKeyValue.ToCharArray()(i) <> Nothing) Then tempStr = tempStr + sKeyValue.ToCharArray()(i) End If If sKeyValue.ToCharArray()(i) = Nothing Then 'MsgBox(tempStr) StrList.Add(tempStr) '每組完一個section,就丟StrList tempStr = "" '清空組section的temp exitFor = 1 End If Next '顯示最後一個section MsgBox(StrList.Item(StrList.Count)) '捉最後一個section的名稱 End Sub ini內容多時候,真的挺慢的,因為一個字元一個字元去串, 雖然成功捉到所有section,但超級慢. 各位前輩們,該如何改善它呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.135.168.66 ※ 編輯: sakiman 來自: 220.135.168.66 (07/02 02:04)