Results 1 to 4 of 4

Thread: AAAUUURRGH! Create a Function

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Question

    Ok..it has been so long since i have done this that i cant get it to work!!! AAAUUURRGGGHH!!!

    this is the function:
    Code:
    Public Function MapPos(X As Integer, Y As Integer)
    MyLoc.X = X * 217
    MyLoc.Y = Y * 217
    MyShip.Left = MyLoc.X
    MyShip.Top = MyLoc.Y
    End Function
    trying to call the function:
    Code:
    Private Sub Command1_Click()
    z = 1
    g = 5
    MapPos z, g
    End Sub
    I get a ByRef Type Mismatch and it points to the z???!!??

    ok...Help PLEASE!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    Not sure but declare z and g as integer

  3. #3
    New Member
    Join Date
    Oct 2000
    Location
    Houston, Texas
    Posts
    11

    Declare Your Variables As An Int

    You obviously do not have Option Explicit Turned On
    for Variable Declaration.

    Change To

    Private SubCommand1_Click()
    'Or Dim z As Integer, g As Integer if you prefer
    Dim z%, g%

    z = 1
    g = 5
    Call MapPos(z, g)
    'Or Ret_Val = MapPos(z, g) if you want to get a
    ' a value returned
    End Sub

    Corby Nichols



    [Edited by Corby on 11-22-2000 at 12:55 PM]

  4. #4

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Talking oops!

    oh yeah...
    Dont I feel stupid. I did declare Z & G but i did this
    Dim z,g as integer (not dim Z as intger, g as integer)

    Y'know...sometime ya just blank on something that is staring you in the face!

    THANKS!

    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

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