×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Implicit data type conversion?

Implicit data type conversion?

Implicit data type conversion?

(OP)
Colleagues,

I'm going through the code written by another programmer some 5-6-7 years ago.
I came across some strange statements that, IMHO, must generate error, but apparently it does not do it coz the code works. In essence, it's a memvar declared as string and later assigned an Int value, e.g.

CODE --> vbnet

Dim BlaBlaBla As String = ""
' And later on
BlaBlaBla = 0 
I can't recall that VB6 allowed such implicit data type conversion, but apparently VB .NET 2012 does... or - does it?
Please educate me.
TIA!

Regards,

Ilya

RE: Implicit data type conversion?

Yep, VB6 certainly used to allow it. And yes, VB.NET does it - still does it in VS2019. Option Strict On would catch this for you.

RE: Implicit data type conversion?

(OP)
Hmm... I look at the Application.Designer, Resources.Designer and Settings.Designer - all three have Option Strict On... and this line of code is in the main cycle, it must have being executed, and it still ain't erring - ?

Regards,

Ilya

RE: Implicit data type conversion?

Just to be certain - Enabling Option Strict does not actually switch this on - it simply inserts Option Strict On in new modules. So, if the module (be it a code, form or class module) does not have the line Option Strict On at the top, then it isn't enforced. And when it IS enforced, it is a design time error, not a run time one.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close