|
-
Oct 8th, 2010, 02:51 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] How to seperate a string?
I need to know how to separate a line that the user types into a text box, and separate them by each character, and do something with that character. How would i do this? I also need to be able to calculate the total number of characters typed. Thanks.
-
Oct 8th, 2010, 03:14 PM
#2
Re: How to seperate a string?
I would imagine the Split() function to split up your string and the Len() function to return the character count. Note: Len() counts spaces too!
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Oct 8th, 2010, 03:20 PM
#3
Thread Starter
Fanatic Member
Re: How to seperate a string?
Okay. After the split function, how would i assign the character to a variable?
-
Oct 8th, 2010, 04:12 PM
#4
Re: How to seperate a string?
Split function will place the results in an array.
-
Oct 8th, 2010, 04:16 PM
#5
Thread Starter
Fanatic Member
Re: How to seperate a string?
Oh. Ok. So like
arrExample() = Split(txtExample.text)
?
-
Oct 8th, 2010, 04:19 PM
#6
Re: How to seperate a string?
Like this. Note the array as baja_yu stated.
Code:
Option Explicit
Private Sub Command1_Click()
Dim strWords As String
Dim strSplit() As String
Dim i As Integer
strWords = "A String comprised of six words"
strSplit = Split(strWord, " ") ' split strWords at each space char.
For i = 0 To UBound(strSplit)
MsgBox strSplit(i)
Next i
End Sub
Last edited by CDRIVE; Oct 8th, 2010 at 04:25 PM.
Reason: Changed Var name to something more meaningful
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Oct 8th, 2010, 04:22 PM
#7
Thread Starter
Fanatic Member
Re: How to seperate a string?
how can i get it to split each character though? like if the word was "Hello" it would do H e l l and o.
-
Oct 8th, 2010, 04:23 PM
#8
Re: How to seperate a string?
Use Mid$ in a For loop instead of split for that.
Code:
For I = 1 To Len(Text1.Text)
MsgBox Mid$(Text1.Text, I, 1)
Next I
-
Oct 8th, 2010, 04:26 PM
#9
Thread Starter
Fanatic Member
Re: How to seperate a string?
Sweet! That worked baja_yu. Thanks so much!
-
Oct 8th, 2010, 04:33 PM
#10
Re: How to seperate a string?
 Originally Posted by Gamemaster1494
how can i get it to split each character though? like if the word was "Hello" it would do H e l l and o.
I should have read your first post more thoroughly. Mid(), as already stated by B_Y.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Oct 8th, 2010, 04:36 PM
#11
Thread Starter
Fanatic Member
Re: [RESOLVED] How to seperate a string?
Hehe. Thanks also CDRIVE. =)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|