none
VB2010 - can i do variables 'pointers'?

    Question

  • i have these metod:

    Public Sub Jump(ByVal height As Integer, ByRef direction As Integer)
            If tmrGravidadeSalto.Enabled = True Then Exit Sub
            intJump = CInt(height / 2)
            blnJumpLeft = direction
            If intJump > 0 Then tmrGravidadeSalto.Start()
        End Sub
    blnJumpLeft recives the direction value. but imagine the direction value is changed. can i get it's reference on blnJumpLeft?


    • Edited by Cambalinho Thursday, March 16, 2017 10:23 PM
    Thursday, March 16, 2017 10:19 PM

Answers

  • I don't understand your question... what is "c hanged"?  Can you explain what you expect to happen when this code runs versus what actually happens?  Because I don't think the code does what you think it does... passing direction ByRef indicates that you would set the value of direction from within the method, not just consume the value.

    As far as variable pointers go, no, you can't access them like pointers in C.  But you don't need to.  Whatever the problem is, getting a pointer to a variable isn't the solution.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by Cambalinho Friday, March 17, 2017 9:49 PM
    Thursday, March 16, 2017 11:07 PM
    Moderator
  • As I already said, no, you can't.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by Cambalinho Friday, March 17, 2017 9:49 PM
    Friday, March 17, 2017 9:31 PM
    Moderator

All replies

  • I don't understand your question... what is "c hanged"?  Can you explain what you expect to happen when this code runs versus what actually happens?  Because I don't think the code does what you think it does... passing direction ByRef indicates that you would set the value of direction from within the method, not just consume the value.

    As far as variable pointers go, no, you can't access them like pointers in C.  But you don't need to.  Whatever the problem is, getting a pointer to a variable isn't the solution.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by Cambalinho Friday, March 17, 2017 9:49 PM
    Thursday, March 16, 2017 11:07 PM
    Moderator
  • Cambalinho,

    Only you and really you knows what happens in 

    tmrGravidadeSalto.Start()

    It does not return something, it just start. 

    What kind of answer you expect from us?


    Success
    Cor

    Thursday, March 16, 2017 11:07 PM
  • Cambalinho,

    Only you and really you knows what happens in 

    tmrGravidadeSalto.Start()

    It does not return something, it just start. 

    What kind of answer you expect from us?


    Success
    Cor

    I can make a really good guess...

    Its a Timer instance being used to control "gravity" during a jump. 

    Reading it again I guess that was "changed" - so the direction has changed mid-jump but this calculation is long since over.

    I'm willing to bet this boils down to the design and not having a single consistent game loop to execute all logic and rendering.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Thursday, March 16, 2017 11:13 PM
    Moderator
  • ok. let me ask in a diferent way: can i create pointers on VB2010, more or less like C. or what we have is just 'byref' on parameters and adressof() for functions\subs?
    Friday, March 17, 2017 8:31 PM
  • As I already said, no, you can't.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by Cambalinho Friday, March 17, 2017 9:49 PM
    Friday, March 17, 2017 9:31 PM
    Moderator