 |
Anthony's VBA Forum Where the knowledge is shared |
|
|
View previous topic :: View next topic |
Author |
Message |
bshaen
Joined: 10 Jan 2005 Posts: 9 Location: malaysia
|
Posted: Mon Jan 17, 2005 8:54 pm Post subject: how many cols of strarr had splited?? |
|
|
strarr = Split(str1, " ")
i would like to ask, how we know, how many cols of strarr had splited?? what the method i can get the total n of strarr?? <<strarr(n)>>
and i want split the string that have more than 2 places, or more than 1 tab, how can i recognize it??? _________________ bshaen |
|
Back to top |
|
 |
Data Moderator


Joined: 06 Oct 2004 Posts: 33 Location: NY
|
Posted: Tue Jan 18, 2005 12:40 pm Post subject: Count the Number of Spaces in a String Using VBA |
|
|
Hi Bshaen,
Use the following to get the column number:
Note that the column number is the final counter value plus 1
Sub CountSpace()
Dim str As String
Dim strLength As Integer
Dim counter As Integer
Dim strLetter As String
str = "ab c d efg hi jklm"
strLength = Len(str) 'Get the length of the string
strLetter = Chr(32) 'Chr(32) = space
counter = 0
For i = 1 To strLength
If Mid(str, i, 1) = strLetter Then
counter = counter + 1
End If
Next i
MsgBox "The number of space(s) is " & counter & "!"
End Sub
If the text file is tab delimited, then there will be a symbol between each column. Just copy and paste the symbol into the code. _________________ Data
Knowledge is Power |
|
Back to top |
|
 |
bshaen
Joined: 10 Jan 2005 Posts: 9 Location: malaysia
|
Posted: Tue Jan 18, 2005 11:56 pm Post subject: how to know total record in text file |
|
|
cool.. thank Data.
except using the c=c+1 in every input record. what the method else i can using to know tatal record in text file
 _________________ bshaen |
|
Back to top |
|
 |
Guest
|
Posted: Wed Jan 19, 2005 3:00 pm Post subject: |
|
|
Since the text file is not a database, I do not think there is a property that can return the total rows/records. But I might be wrong. No one knows everything. Please post your answer here if you find out. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|