Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

VB.Net & VB 6.0 Syntax's

VB.NET form syntax

  • Please log in to reply
10 replies to this topic

#1 travy92

travy92

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 73 posts

Posted 17 September 2007 - 01:17 AM

Well i was just reading through a VB.NET book and i saw this one syntax that i was unsure how to convert into VB 6.0 Syntax.

This code is placed in General Declarations (VB.NET):

Dim Number1 As Integer = 0


The "= 0" part isn't supported in VB 6.0 so if anyone could help me covert the code into VB 6.0 form it would be nice :D.

Thanks in advance.
  • 0
[SIGPIC]C:\Users\Travis\Desktop\Image Converter\Knight1.bmp[/SIGPIC]

#2 kkelly

kkelly

    CC Regular

  • Just Joined
  • PipPipPip
  • 46 posts

Posted 17 September 2007 - 04:03 AM

It's been a little while since I worked with the VB 6 compiler, but I think the problem is that you can't assign a value to a variable outside of a method (function or sub), unless it is a constant.
  • 0

#3 travy92

travy92

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 73 posts

Posted 17 September 2007 - 09:46 PM

So how would i go about writing the code in VB 6.0?
  • 0
[SIGPIC]C:\Users\Travis\Desktop\Image Converter\Knight1.bmp[/SIGPIC]

#4 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 18 September 2007 - 07:00 AM

If I'm not wrong it would be
In the General Declerations Write:
Dim Number1 As Integer


And in the Form_Load() Write:

Number1=0


Simple :)
  • 0

#5 o0TheNerd0o

o0TheNerd0o

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 59 posts

Posted 18 September 2007 - 12:13 PM

It doesn't matter where you Dimension the variable. You can't assign a value to it. Unless you dimension as follows:

Const VariableName as Integer = 10

If you don't want it to be constant, this is the correct method:

Dim VariableName as Integer
VariableName = 10

You can use either method in the General Declarations, or under sub or function. Hope this helps.
  • 0
Option Explicit
:cool:

#6 travy92

travy92

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 73 posts

Posted 19 September 2007 - 11:59 PM

Umm, when i put:
Dim VariableName As Integer
VariableName = 10

It comes up with an error when i press play.
the error says "Compile Error: Invalid outside procedure"
  • 0
[SIGPIC]C:\Users\Travis\Desktop\Image Converter\Knight1.bmp[/SIGPIC]

#7 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 20 September 2007 - 01:18 AM

Umm, when i put:
Dim VariableName As Integer
VariableName = 10

It comes up with an error when i press play.
the error says "Compile Error: Invalid outside procedure"


Of course, the VariableName = 10 should be put as I told you in my post, under Form_Load() so it is set to 10 as soon as the application starts.. but heh, he thinks he is an expert :)
  • 0

#8 travy92

travy92

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 73 posts

Posted 20 September 2007 - 03:25 AM

Ahh! TheComputerMaster thanks very much. I followed your instructions and it worked :D.
Now i need to find out how to change this code:

Date.Now.AddMinutes(Difference1*60 _
- Difference2*60)


Into VB 6.0 syntax from VB.NET

Any help?
  • 0
[SIGPIC]C:\Users\Travis\Desktop\Image Converter\Knight1.bmp[/SIGPIC]

#9 o0TheNerd0o

o0TheNerd0o

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 59 posts

Posted 20 September 2007 - 07:46 AM

I never said I was anything. I feel like I'm repeating myself... I remember in another post I was explaining to you that I wasn't "1337" either. So yeah, you got me this one time. YAY! You're better than me now. Good job!
  • 0
Option Explicit
:cool:

#10 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 20 September 2007 - 01:31 PM

Ahh! TheComputerMaster thanks very much. I followed your instructions and it worked :D.
Now i need to find out how to change this code:


Into VB 6.0 syntax from VB.NET

Any help?


Well explain what that is supposed to do, and perhaps we may be able to help you.

TheNerd, if that is not sarcasm, then thanks.
  • 0

#11 o0TheNerd0o

o0TheNerd0o

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 59 posts

Posted 20 September 2007 - 01:34 PM

It was a little bit of both. But at least I admitted I was caught wrong on this one...
  • 0
Option Explicit
:cool:





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download