|
-
Oct 20th, 2005, 12:56 PM
#1
Thread Starter
Hyperactive Member
W_o_r_d
Ok how would i achieve this. I have a current method but its very long.
Code:
Public Sub Fourletters
str = Mid(Word, 1) & "_" & Mid(Word, 2) & "_" & Mid(Word, 3)& "_" & Mid(Word, 4)
list1.additem str
so i have this 16 times for each length of word. Then i have to do
Code:
If Len(Word) = 2 Then Call TwoLetters
If Len(Word) = 3 Then Call ThreeLetters
im sure there is a quicker method.
Thanks in advance.
-
Oct 20th, 2005, 01:05 PM
#2
Fanatic Member
Re: W_o_r_d
that's not that long, if you want you can break it up liek this:
Code:
Public Sub Fourletters
str = Mid(Word, 1) & _
"_" & Mid(Word, 2) & _
"_" & Mid(Word, 3) & _
"_" & Mid(Word, 4)
list1.additem str
-
Oct 20th, 2005, 01:05 PM
#3
PowerPoster
Re: W_o_r_d
dim newstring as string
for x = 1 to len(oldstring)
newstring = newstring & mid(oldstring,x,1) & " "
next x
-
Oct 20th, 2005, 01:07 PM
#4
Re: W_o_r_d
VB Code:
Private Function Splitword(strWord As String) As String
For x = 1 To Len(strWord)
If x = Len(strWord) Then
Splitword = Splitword & Mid(strWord, x, 1)
Else
Splitword = Splitword & Mid(strWord, x, 1) & "_"
End If
Next
End Function
Private Sub Form_Load()
List1.AddItem Splitword("TESTING")
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Oct 20th, 2005, 01:07 PM
#5
Hyperactive Member
Re: W_o_r_d
This seems to work:
VB Code:
str = Left$(Word, 1)
For I = 2 To Len(Word)
str = str & "_" & Mid$(Word, I, 1)
Next
-
Oct 20th, 2005, 01:07 PM
#6
Re: W_o_r_d
How about this:
VB Code:
Private Sub Command1_Click()
MsgBox AddUnderscore("Word")
End Sub
Private Function AddUnderscore(strWord As String) As String
Dim strTemp As String
Dim a As Long
For a = 1 To Len(strWord)
strTemp = strTemp & Mid(strWord, a, 1) & "_"
Next a
AddUnderscore = Left(strTemp, Len(strTemp) - 1)
End Function
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Oct 20th, 2005, 01:09 PM
#7
Re: W_o_r_d
It would seem that 2:07 PM was a very popular time for this post. Good job by all!
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Oct 20th, 2005, 01:17 PM
#8
Re: W_o_r_d
ROFL! funny thing is..
none of the suggestions are the same!
everyone had a slightly diff way to do it! 
(mine's the best of course... ) j/k!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Oct 20th, 2005, 01:21 PM
#9
Re: W_o_r_d
The smallest code for this you could ever get for this:
VB Code:
Private Sub Command1_Click()
Dim s As String
s = "Word"
sformat = "@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@"
MsgBox Format(s, Left(sformat, 2 * Len(s) - 1))
End Sub
Pradeep
-
Oct 20th, 2005, 02:24 PM
#10
Re: W_o_r_d
 Originally Posted by [A51g]Static
ROFL! funny thing is..
none of the suggestions are the same!
everyone had a slightly diff way to do it!
(mine's the best of course...  ) j/k!
And another way :
VB Code:
Option Explicit
Private Sub Form_Load()
Dim Str As String
Str = "Word"
Debug.Print Left(Replace(StrConv(Str, vbUnicode), Chr(0), "-"), Len(Str) * 2 - 1)
End Sub
-
Oct 20th, 2005, 02:38 PM
#11
Re: W_o_r_d
very nice!!
(beats mine lol)
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
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
|