|
-
Nov 7th, 2008, 02:27 PM
#1
Thread Starter
Fanatic Member
Help me in this coding in VB
Hello sir,
Help me in this coding
My recordset contains 11-2, 5-2, 5, 6 datas in no1 field
I used the below coding to search and replace it with but not working properly.
Private Sub Command1_Click()
rs.Open "check1", db, 3, 2
Dim TestString As String
TestString = rs.Fields("no1")
Dim aString As String
aString = Replace(TestString, "*-*", "*/*")
MsgBox aString
End Sub
The output i got is only 11-2
Thank you sir.
-
Nov 7th, 2008, 02:43 PM
#2
Re: Help me in this coding in VB
Replace(TestString,"-","/")
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Nov 7th, 2008, 02:49 PM
#3
Thread Starter
Fanatic Member
Re: Help me in this coding in VB
Hello sir,
I changed that, but it is checking for only first data in recordset
I need to check for all datas in recordset
-
Nov 7th, 2008, 05:54 PM
#4
Re: Help me in this coding in VB
Loop thru the recordset
Code:
Do While rs.EOF=False
... do stuff
rs.MoveNext
Loop
-
Nov 8th, 2008, 02:20 AM
#5
Thread Starter
Fanatic Member
Re: Help me in this coding in VB
 Originally Posted by LaVolpe
Loop thru the recordset
Code:
Do While rs.EOF=False
... do stuff
rs.MoveNext
Loop
I used this code and i got the answer and now what i need is
The coding is checking and replacing only "-" and "/".
(ie) 11-2 becomes 11/2
But the same recordset also contains data like this 5,6,7 etc
i need this to be replaced by 5/1, 6/1, 7/1 etc
Pls help me in this coding.
Thank you sir.
-
Nov 8th, 2008, 08:02 AM
#6
Re: Help me in this coding in VB
Well, you will need to do 2 things.
1. If there is a dash then replace it with a slash
2. If there is not a dash then add /1
Simply test it first: If InStr(TestString,"-") Then replace else add /1
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
|