因為很多新手(包括我)都不是很了解字串函數,希望各位大大們有空可以來了解一下。
這個程式的功能是專門解之前某位版友的問題:
00123456 - E8 33 44 55 66 - CALL 00223344
00123458 - 56 - PUSH EAX
怎麼切字串存陣列。
下載:http://www.badongo.com/file/13322493
http://bbs.wefong.com/viewthread ... &extra=page%3D1
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As String = TextBox1.Text
Dim Flag As Boolean = False
Dim GG(100) As String
Dim w = 0, x = 0, y = -1, i As Integer
For i = 1 To Len(a)
If i = Len(a) Then
y += 1
GG(y) = Mid(a, w, i - w)
ElseIf IsSpace(Mid(a, i, 1)) = True Then
If Flag = False Then
Flag = True
x = i
End If
If w <= x Then
If IsSpace(Mid(a, i + 1, 1)) = False Then
y += 1
GG(y) = Mid(a, w, x - w)
Flag = False
End If
Else
w = i
End If
Else
If w <= x Then
w = i
End If
End If
Next
ListBox1.Items.Clear()
For i = 0 To y
ListBox1.Items.Add(GG(i) & ";")
Next
End Sub
Function IsSpace(ByVal a As String) As Boolean
If Asc(a) = 32 Or Asc(a) = 10 Or Asc(a) = 13 Or Asc(a) = 45 Then
Return True
Else
Return False
End If
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim a As String = TextBox1.Text
Dim d() As String
a = Replace(a, "-", "")
a = Replace(a, Chr(13) & Chr(10), " ")
For i = 0 To 50
a = Replace(a, " ", " ")
Next
d = Split(a, " ")
ListBox1.Items.Clear()
For i = 0 To UBound(d) - 1
ListBox1.Items.Add(d(i) & ";")
Next
End Sub
End Class
留言列表