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.
Re: Help me in this coding in VB
Replace(TestString,"-","/")
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
Re: Help me in this coding in VB
Loop thru the recordset
Code:
Do While rs.EOF=False
... do stuff
rs.MoveNext
Loop
Re: Help me in this coding in VB
Quote:
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.
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