VBscript doesnt return error, but VB.net returns

Status
Not open for further replies.

AftPeakTank

Member
Joined
Apr 21, 2010
Messages
8
Programming Experience
Beginner
Ok, here is the problem,

in vbscript, i was reading parts of streams

i.e.

VB.NET:
		teststrid = left (strLine,8)
		teststrnm =rtrim( mid (strLine,15,30))
		teststrx = mid (strLine,57,8)
		teststr = left (strLine,3)
		strFormcode = left (strLine, 10)
		strSymmetrycode = left (strLine,14) 
		strSigncode = left (strLine, 10)

Even in cases that strLine length was less than the index used to split the string, the program kept running.

Now i am trying to do the same in VB.net, but since the strLine is not always bigger than the index used to break the string, it ives an error.

I do not want to use try catch, because i will have very dirty and uselless code.

I was thinking something like resume next, but i guess it doesnt exist anymore.

Please help....
 
Welcome to modern programming. First off in .Net everything is zero based (starts with zero, not 1), whereas in vbscript most of it's 1 based (starts with 1) so if you want to convert that to .Net shift your code so it starts reading things 1 position to the left.

Second, why on earth would you use such horrible code in .Net? .Net has so many tools and methods that avoid a horrible mess of code.
 
Wow, that was 2 replyies wich did not help at all!!!!!

Ok i solved the problem.

What i did, is to use Resume on error.

So everything now works as in vbscript.
 
Wow, instead of looking at how vb.net works and what a modern technique would be to accomplish this in .Net you decided to implement the worst error handling ever known to programming, which allows you to conveniently ignore the mess and the root of the problem. Did not see that coming... :rolleyes:
 
Wow, instead of looking at how vb.net works and what a modern technique would be to accomplish this in .Net you decided to implement the worst error handling ever known to programming, which allows you to conveniently ignore the mess and the root of the problem. Did not see that coming... :rolleyes:

Why it is so hard for some people to understand that, there are cases you need this. In other cases, i would have used if..then, or try.. catch for each one of the variables i am trying to fill.

There is no problem if i have an error duringthe operation and even if i was using try..catch i would continue to the next try..catch for the next variable.

I understand that it is dangerous, but you know? Nuclear energy is dangerous too, why then we have nuclear powerplants?

Just in case you think nuclear energy will vanish because its dangerous, how about cars? It is not what it can do, is wht you do with it....

Anyway...

As i say, you learn a little poem, you say it...What i know is that with just 2 extra lines of code i achieved what i wanted...And Vbscript, sometimes worths much more than real programming, the reason is that i run it inside a 3d program and i can easily make my own commands or macros....But why would you care? You are a REAAL programmer....

WOOWWW
 
Yes, vbscript is useful too, I use it myself but if I were to make a vb.net app that does the same task as the script does, I certainly wouldn't just copy the script's code and paste it into a .Net app then add "On Error...." and move on, doing so is just plain retarded.

Yes, vb.net supports the legacy functions (mid, left, trim, right) but in .Net you should never have a need to use them, they're there for the vb6 upgrade wizard (which I hear VB2010 doesn't even have it). Instead I would use the .Net things built in like:
.SubString(), .Trim(), etc...

But this is turning into a senseless debate.
 
Status
Not open for further replies.

Latest posts

Back
Top