Anthony's VBA Forum Index Anthony's VBA Forum
Where the knowledge is shared
Menu
 Anthony's VBA Forum IndexHome Page
 Anthony's VBA Forum IndexForum Index
FAQFAQ
MemberlistMemberlist
UsergroupsUsergroups
RegisterRegister
ProfileProfile
Log in to check your private messagesMessages
Log inLogin/Out

Quick Search

Advanced Search

Links
Consulting
Products

Who's Online
[ Administrator ]
[ Moderator ]


how many cols of strarr had splited??

 
Post new topic   Reply to topic     Anthony's VBA Forum Index -> Portfoilio Optimization
View previous topic :: View next topic  
Author Message
bshaen



Joined: 10 Jan 2005
Posts: 9
Location: malaysia

PostPosted: Mon Jan 17, 2005 8:54 pm    Post subject: how many cols of strarr had splited?? Reply with quote

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
View user's profile Send private message
Data
Moderator
Moderator


Joined: 06 Oct 2004
Posts: 33
Location: NY

PostPosted: Tue Jan 18, 2005 12:40 pm    Post subject: Count the Number of Spaces in a String Using VBA Reply with quote

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
View user's profile Send private message
bshaen



Joined: 10 Jan 2005
Posts: 9
Location: malaysia

PostPosted: Tue Jan 18, 2005 11:56 pm    Post subject: how to know total record in text file Reply with quote

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
Question
_________________
bshaen
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Jan 19, 2005 3:00 pm    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic     Anthony's VBA Forum Index -> Portfoilio Optimization All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
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