Hi all,
I'm pretty new to VB.net, having only recently migrated from VB5(!). I'd appreciate any help at all with the following problem that I have on a project;

I'm reading data in from a comma-separated text file and storing the data in an array for later use. Some of the values are to remain as strings, and I need to convert some to integers, for which I was trying to use, for example, integer.parse(ar(0)).

My problem is that the string values are randomly distributed through the text file, so I need to be able to test whether the string can be converted at all before doing the conversion.

So - can anyone tell me if there is there a way to do this, or should I be looking for an alternative method?

Thanks, Gavin

Recommended Answers

All 3 Replies

if isnumeric(myArray(x)) = true then

try and catch could be used to, but isnumeric is easier.

Excellent! Very many thanks - that part of things now works like a dream.

I considered about try and catch, although I didn't go for it in the end because it seemed like it would be so ungainly that there ought to be something better obviously, there was...

Thanks again.

np

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.