Solved

Accessing VB 6.0 functions in VB.NET

Posted on 2011-03-08
16
215 Views
Last Modified: 2012-05-11
Hello Experts -

While trying to figure out how to test a string to determine if it held numeric data, I came across a web site that claimed that the functions found in the old standby VB were accessable in VB.NET.

Specifically, the site said:

"Looking for IsNumeric in VB.NETt

"I was wondering why a VB.NET class file was throwing up errors when I called the IsNumeric function the other day. After some googling i found out from Roy Osherove’s blog that you now need to import the Microsoft.VisualBasic Namespace to use this and a bunch of other once standard functions."

Is this true? If so, how exactly woud I go about importing the VB Namespace?

Maybe this is already common knowledge. Don't be too tough on me here. I'm only a beginner.

0
Comment
Question by:gbmcneil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
  • 3
16 Comments
 
LVL 8

Accepted Solution

by:
PagodNaUtak earned 125 total points
ID: 35076249
Put this on top your code:

Imports Microsoft.VisualBasic
0
 

Author Comment

by:gbmcneil
ID: 35076288
And, then I can take a VB 6.0 function like DateDiff and use it in VB.NET?
0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 35076347
After putting it on top of your code you can use the IsNumeric Function of VB6 but as a suggestion avoid using those functions.

0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 35076399
Yes, but this approach is not recommended...
0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 35076412
0
 

Author Comment

by:gbmcneil
ID: 35076590
Are we talking potential corruption here. Or, just bad programming practice?
0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 35076887
We are talking about bad programming practice...

VB.Net is a new language, if you want to use the full potencial of vb.net avoid using functions that is from vb 6.0. There are new function in VB.net you just have to dig it down.

I understand what you are into, I used to be a vb 6.0 guy but when I understand the vb.net language (not an expert on this) I realize I have to forget those vb 6.0 function and move forward, if not, what is the sense of using this new language than programinng in vb 6.0.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 35077049
I agree that you should strive to use only the newer native VB.Net functions.  One big reason is that the legacy functions are still ONE based, while the newer functions are ZERO based.  When you allow yourself to mix the old and new you can inadvertently create "off by one" bugs that are very hard to troubleshoot...
0
 

Author Closing Comment

by:gbmcneil
ID: 35077230
Thanks very nuch for your help.
0
 

Author Comment

by:gbmcneil
ID: 35077313
It seems to me that VB.NET's program environment environment is phenominal, if you can just figure out the attribute or method you looking for. This is another way of saying I don't think the documentation is very good.

I spend hours just trying to figure out what function I need. I live on The Experts Exchange because it's the only way to make any progress programming.

Have you ever seen a good reference manual for VB.NET - without all the explanations? Just lists of attributes and methods.

I am led to believe that NET.Framwork consists of a 150,000 such descriptors.  
0
 

Author Comment

by:gbmcneil
ID: 35077351
Hi Idle -

What do you mean by "one based" versus "zero based"?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 35077396
For instance, the legacy Mid() function is replaced with Substring().

Using Mid(), the first character in the string is accessed using 1 (one).
Using Substring(), the first character in the string is accessed using 0 (zero).
0
 

Author Comment

by:gbmcneil
ID: 35077431
Will you tell my mother if I continue to use Mid()?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 35077468
I'm sure she'd be concerned and might stage an intervention!

If you only plan on developing in VB then use whatever floats your boat.  =)

One advantage to learning and using the native .Net functions is that you can theoretically jump to C# easier since the functions will be the same and only the syntax would differ.
0
 

Author Comment

by:gbmcneil
ID: 35077550
That day is not going to occur in my lifetime (and I'm not ninety years old).
0
 

Author Comment

by:gbmcneil
ID: 35078108
A last minute question. Is it called -

Imports Microsoft.VisualBasic.Information

or

Imports Microsoft.VisualBasic.Compatibility

and, if Microsoft.VisualBasic.Information is VB.NET VisualBasic, why would someone load a function library that already exists in VB.NET?
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question