Results 1 to 3 of 3

Thread: [RESOLVED] Side question about UDTs

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Resolved [RESOLVED] Side question about UDTs

    I defined a UDT in these terms,

    Type Curve
    n As Integer
    x() As Single
    y() As Single
    End Type

    Then after I close the IDE and go back to the project at a later time I find the single variables have been converted to upper case

    X() As Single
    Y() As Single

    Not that it matters much but I like them lower case and I just have no idea why this happens.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Side question about UDTs

    VB6 saves variable names globally...

    For example, make 2 functions/subs, both of them with the same variable name (with same type or diferent type, it does not matter), then change the Cation on one of the variables, and see what happens with the other in the ohter function...
    For example
    Code:
    Private Sub Func1()
        Dim TestVariable As String
    End Sub
    
    Private Sub Func2()
        Dim TestVariable As Integer
    End Sub
    Just change "TestVariable" to "Testvariable", and see what happens

    This hapened to me a lot, and it is quite anoying, especially when you include a module/class (that is not made by me) using same variable names as I do. It took me a long time to figure out why I cannot change the variable name, and it always jumps to some other caption state...

  3. #3

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Side question about UDTs

    Quote Originally Posted by CVMichael
    VB6 saves variable names globally...

    For example, make 2 functions/subs, both of them with the same variable name (with same type or diferent type, it does not matter), then change the Cation on one of the variables, and see what happens with the other in the ohter function...
    For example
    Code:
    Private Sub Func1()
        Dim TestVariable As String
    End Sub
    
    Private Sub Func2()
        Dim TestVariable As Integer
    End Sub
    Just change "TestVariable" to "Testvariable", and see what happens

    This hapened to me a lot, and it is quite anoying, especially when you include a module/class (that is not made by me) using same variable names as I do. It took me a long time to figure out why I cannot change the variable name, and it always jumps to some other caption state...
    Well, thanks for clarifying the issue. I smelled something like this but wasn't sure exactly what it was. I'll have to be more imaginative with my variable names, still x,y for coordinates are very intuitive.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

Posting Permissions

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



Click Here to Expand Forum to Full Width