Jump to content

VB.Net & VB 6.0 Syntax's

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic

#1
travy92

travy92

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts
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):

Quote

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.
[SIGPIC]C:\Users\Travis\Desktop\Image Converter\Knight1.bmp[/SIGPIC]

#2
kkelly

kkelly

    Learning Programmer

  • Members
  • PipPipPip
  • 49 posts
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.

#3
travy92

travy92

    Learning Programmer

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

#4
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
If I'm not wrong it would be
In the General Declerations Write:
[HIGHLIGHT="VB"]Dim Number1 As Integer[/HIGHLIGHT]

And in the Form_Load() Write:

[HIGHLIGHT="VB"]Number1=0[/HIGHLIGHT]

Simple :)

#5
o0TheNerd0o

o0TheNerd0o

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
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.
Option Explicit
:cool:

#6
travy92

travy92

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts
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"
[SIGPIC]C:\Users\Travis\Desktop\Image Converter\Knight1.bmp[/SIGPIC]

#7
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts

travy92 said:

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 :)

#8
travy92

travy92

    Learning Programmer

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

Quote

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

Into VB 6.0 syntax from VB.NET

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

#9
o0TheNerd0o

o0TheNerd0o

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
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!
Option Explicit
:cool:

#10
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts

travy92 said:

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.

#11
o0TheNerd0o

o0TheNerd0o

    Learning Programmer

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