Results 1 to 3 of 3

Thread: receiving values back from variable

  1. #1

    Thread Starter
    Member
    Join Date
    May 2000
    Location
    London, UK
    Posts
    39

    Cool

    Hi,

    I have some code and the way this has been written , the reciving function takes in 3 variables as parameters , but only passes back the information into a new variable


    e.g


    runc = callgeo( lat,lon, map)

    I am sending variable :- lat, lon, map to function 'callgeo'
    and receiving this into a variable runc.

    Can I not just receive the information back as 3 separate variables, or what is the best way to approach this in vb.


  2. #2
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510
    A FUNCTION returns a value in a single variable. Try SUB.

    Try making the new variables that you want lat,lon & map assigned to PUBLIC and re-assign the new values in the Sub like so:

    Call callgeo(lat,lon,map)


    Public Sub callgeo(lat,lon,map)

    {
    Your code here for whatever calculations. Then Re-assign the new values of lat,lon & map to your new variables before you exit the sub and they will be updated.

    newvar1 = lat
    newvar2 = lon
    newvar3 = map
    }

    Now newvar1, 2 and 3 will be available throughout the program in 3 seperate variables.

    Hope it helps...

  3. #3
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    You couls also make an UDT to send the values back and let the parameter variables as they are:

    Code:
    'Module
    Type tVars
       x as Long
       y as Long
       z as Long
    End Type
    
    'Anywhere
    Function CallGeo(iLat, iLon, iMap) as tVars
       CallGeo.x = 324
       CallGeo.y = 35
       CallGeo.z = 465
    End Function
    
    'Code
    Dim Temp as tVars
    
    Temp = CallGeo( 1, 2, 3 )
    
    MsgBox "Returns: " & Temp.x & ". " & Temp.y & "." & temp.z

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