Private Sub Command1_Click()
Dim TextArr() As String
TextArr = Split(Text1.Text, ".")
Dim i As Integer
Dim ArrCount As Integer
ArrCount = UBound(TextArr)
For i = 0 To ArrCount - 1
List1.AddItem (TextArr(i))
Next
End Sub
It separates all the numbers, and adds them to a listbox.
Here is all the numbers organised into 3 separate listboxes :
Code:
Option Explicit
Private Sub Command1_Click()
Dim TextArr() As String
TextArr = Split(Text1.Text, ".")
Dim i As Integer
Dim ArrCount As Integer
ArrCount = UBound(TextArr)
For i = 0 To ArrCount - 1
If Len(TextArr(i)) = 2 Then
List1.AddItem (TextArr(i))
ElseIf Len(TextArr(i)) = 3 Then
List2.AddItem (TextArr(i))
ElseIf Len(TextArr(i)) = 4 Then
List3.AddItem (TextArr(i))
End If
Next
End Sub
To count the items I have used Len.
I am attaching a sample for you because I am such a nice guy today
Here is all the numbers organised into 3 separate listboxes :
Code:
Option Explicit
Private Sub Command1_Click()
Dim TextArr() As String
TextArr = Split(Text1.Text, ".")
Dim i As Integer
Dim ArrCount As Integer
ArrCount = UBound(TextArr)
For i = 0 To ArrCount - 1
If Len(TextArr(i)) = 2 Then
List1.AddItem (TextArr(i))
ElseIf Len(TextArr(i)) = 3 Then
List2.AddItem (TextArr(i))
ElseIf Len(TextArr(i)) = 4 Then
List3.AddItem (TextArr(i))
End If
Next
End Sub
To count the items I have used Len.
I am attaching a sample for you because I am such a nice guy today
thanks HanneSThEGreaT...
but now i have new case....
can u tell me how to read and split the number then read number or digit after cross symbol
InStr$() will search within a string, for any patter you want.
Code:
Option Explicit
Dim strBuff As String
Dim str() As String
Private Sub Command1_Click()
Dim x As Long, st As String
x = Search(Text2.Text, Text1.Text)
If x > 0 Then
MsgBox "Found and deleted. Score= " & x
Else
MsgBox "Not found..."
End If
For x = 0 To UBound(str)
st = st & str(x) & vbCrLf
Next x
MsgBox st
End Sub
Private Sub Form_Load()
Dim x As Integer
Dim ff As Integer
Text1.Text = App.Path & "\scores.txt"
Text2.Text = "David"
ff = FreeFile
Open Text1.Text For Input As #ff
strBuff = Input(LOF(ff), ff)
Close #ff
str() = Split(strBuff, vbCrLf)
End Sub
Function Search(n As String, f As String) As Integer
' This finds a person's score, and removes the line
' it rewrites the file
Dim x As Integer, out As String, ff As Integer
Dim num As Long
For x = 0 To UBound(str)
If InStr(str(x), n) > 0 Then
n = InStr(str(x), "=") + 1
num = Val(Mid(str(x), n, Len(str(x)) - n + 1))
Else
out = out & str(x) & vbCrLf
End If
Next x
ff = FreeFile
Open f For Output As #ff
Print #ff, out
Close #ff
str() = Split(out, vbCrLf)
Search = num
End Function
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.