Handling Comma while reading a .txt file

  • Thread starter Thread starter Avi
  • Start date Start date
A

Avi

Hi All,

I am reading a text file after converting it to a record set. I have
defined a custom delimiter (|). My txt file looks like

**************
a|b|d
1|4,11|12
3|2,13|14
**************

and I am reading the record set like

******************************************
While oRs.EOF <> "True"
MsgBox oRs(0).Value
MsgBox oRs(1).Value
MsgBox oRs(2).Value
oRs.MoveNext
Wend
******************************************

Problem I am facing is; the second column b is read as date and I am
not getting any clue why. Messagebox oRs(1).Value displays values as
4:11:00 AM and I want to see this as 4,11 only

Please let me know if you have any idea why this is happening and how
can i fix the issue.

Any help on this issue is highly appreciated.

Thanks,
Avinash
 
Try declaring Ors as a string

Dim Ors(3) as String

You probably don't have it declared so it is assumed to be a variant. The
Variant will convert the 4,11 to a date.
 
I converted the code to
Dim a As String
While oRs.EOF <> "True"
a = oRs(1).Value
MsgBox oRs(0).Value
MsgBox a 'oRs(1).Value
MsgBox oRs(2).Value
oRs.MoveNext

Wend
but no luck :(
 
See my reply in your other thread...

Tim

I converted the code to
Dim a As String
While oRs.EOF <> "True"
a = oRs(1).Value
MsgBox oRs(0).Value
MsgBox a 'oRs(1).Value
MsgBox oRs(2).Value
oRs.MoveNext

Wend
but no luck :(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top