Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: VB.Net & VB 6.0 Syntax's

  1. #1
    travy92's Avatar
    travy92 is offline Learning Programmer
    Join Date
    Sep 2007
    Location
    Australia
    Posts
    76
    Rep Power
    17

    Question VB.Net & VB 6.0 Syntax's

    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 .

    Thanks in advance.
    C:\Users\Travis\Desktop\Image Converter\Knight1.bmp

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    kkelly's Avatar
    kkelly is offline Learning Programmer
    Join Date
    Sep 2007
    Posts
    50
    Rep Power
    0
    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.

  4. #3
    travy92's Avatar
    travy92 is offline Learning Programmer
    Join Date
    Sep 2007
    Location
    Australia
    Posts
    76
    Rep Power
    17
    So how would i go about writing the code in VB 6.0?
    C:\Users\Travis\Desktop\Image Converter\Knight1.bmp

  5. #4
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    101
    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

  6. #5
    o0TheNerd0o's Avatar
    o0TheNerd0o is offline Learning Programmer
    Join Date
    Sep 2007
    Location
    I.E. So-cal
    Posts
    61
    Rep Power
    0
    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

  7. #6
    travy92's Avatar
    travy92 is offline Learning Programmer
    Join Date
    Sep 2007
    Location
    Australia
    Posts
    76
    Rep Power
    17
    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"
    C:\Users\Travis\Desktop\Image Converter\Knight1.bmp

  8. #7
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    101
    Quote Originally Posted by travy92 View Post
    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

  9. #8
    travy92's Avatar
    travy92 is offline Learning Programmer
    Join Date
    Sep 2007
    Location
    Australia
    Posts
    76
    Rep Power
    17
    Ahh! TheComputerMaster thanks very much. I followed your instructions and it worked .
    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?
    C:\Users\Travis\Desktop\Image Converter\Knight1.bmp

  10. #9
    o0TheNerd0o's Avatar
    o0TheNerd0o is offline Learning Programmer
    Join Date
    Sep 2007
    Location
    I.E. So-cal
    Posts
    61
    Rep Power
    0
    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

  11. #10
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    101
    Quote Originally Posted by travy92 View Post
    Ahh! TheComputerMaster thanks very much. I followed your instructions and it worked .
    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.

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts