|
-
Dec 1st, 2001, 04:45 AM
#1
Thread Starter
Lively Member
Sting manipulation
I have a string which some " . " characters, I have to replace the "." in very 3,6,9, 12.....the position with "VBCRLF"
How do I go about it?
-
Dec 1st, 2001, 04:54 AM
#2
Fanatic Member
Use Replace(string,".",vbcrlf) to replace all the "." in your string.
If a post has helped you then Please Rate it!
-
Dec 1st, 2001, 05:13 AM
#3
Thread Starter
Lively Member
Originally posted by VBKNIGHT
Use Replace(string,".",vbcrlf) to replace all the "." in your string.
Yes i know....but how do i find the occurance of the perticular "." catecter in the string?
-
Dec 1st, 2001, 05:21 AM
#4
Addicted Member
Code:
Private Sub Command1_Click()
Dim sstr As String
Dim sreplace As String
Dim i As Integer
sstr = "................................"
For i = 1 To Len(sstr)
If (i Mod 3) = 0 Then
'MsgBox i
sreplace = sreplace + vbCrLf
Else
sreplace = sreplace + Mid(sstr, i, 1)
End If
Next
End Sub
-
Dec 1st, 2001, 05:44 AM
#5
Thread Starter
Lively Member
Thanks E-Link , if i chang the String to "123.456.789.AAA.
I want to get the o/p as
123.
456.
789.
AAA.
can you help me do thath?
-
Dec 1st, 2001, 05:47 AM
#6
Addicted Member
oke , here they are :
Code:
Private Sub Command1_Click()
Dim sstr As String
Dim sreplace As String
Dim i As Integer
sstr = "123.456.789.AAA. "
For i = 1 To Len(sstr)
sreplace = sreplace + Mid(sstr, i, 1)
If (i Mod 4) = 0 Then sreplace = sreplace + vbCrLf
Next
MsgBox sreplace
End Sub
-
Dec 1st, 2001, 06:53 AM
#7
Thread Starter
Lively Member
THnaks again....but
Oh sorry i am getting confused ...infact i wanted to arrage as
for every (i mod 3)th "." a VBCRLf
ie
123.456.789.
AAA.
I used the following code but not working....
VB Code:
Private Sub Command1_Click()
Dim sstr As String
Dim sreplace As String
Dim i As Integer
sstr = "123.456.789.AAA. "
For i = 1 To Len(sstr)
sreplace = sreplace + Mid(sstr, i, 1)
If Mid(sstr, i, 1) = "." Then j = j + 1
If (j Mod 3) = 0 Then sreplace = sreplace + vbCrLf
Next
MsgBox sreplace
End Sub
-
Dec 1st, 2001, 07:19 AM
#8
PowerPoster
Hi
I am totally lost here... why did the Replace function not do what u wanted???? Even if u wanted to replace a single "." with a "." and a vbcrlf u could do that with the replace function... no looping needed. And if u wanted to count all the items u can do that with the replace function also..
Regards
Stuart
-
Dec 1st, 2001, 10:57 AM
#9
Thread Starter
Lively Member
I got it !!!
IT is working ..
here is it
VB Code:
Private Function Format(sstr As String) As String
'Dim sstr As String
Dim sreplace As String
Dim i, j As Integer
For i = 1 To Len(sstr)
sreplace = sreplace + Mid(sstr, i, 1)
If Mid(sstr, i, 1) = "." Then
j = j + 1
If (j Mod 3) = 0 Then sreplace = sreplace + vbCrLf
End If
Next
Format = sreplace
End Function
-
Dec 1st, 2001, 01:05 PM
#10
Frenzied Member
You shouldnt name you function Format, because there already is one in VB.
You just proved that sig advertisements work.
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
|