Results 1 to 6 of 6

Thread: How do i call a sub program?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    10
    Option Base 1



    Sub program(choice As Integer)

    Print "I"

    If choice = 0 Then
    Print "am"
    Else
    Print "drink"
    End If

    End Sub

    Private Sub Command1_Click()
    Dim x As Integer
    Dim wArray(5) As String

    wArray(1) = E
    wArray(2) = V
    wArray(3) = I
    wArray(4) = A
    wArray(5) = N

    Call iysam(2)


    For x = 1 To 5
    Print wArray(x)
    Next x

    Call iyam(0)
    For x = 5 To 1 Step -1
    Print wArray(x)


    End Sub



    when i run it i get a error on the call iysam(2).And when i put iyam after Sub Program it gives me a error too.

    like this :Sub program iyam(choice As Integer)-gets a error




    Ummm now how do I do that?

  2. #2
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510
    You need to drop the program from the sub call and name it iysam() like so:

    Your code now =

    Sub program (choice as integer)


    Your code should =

    Sub iyam(Choice!)

    Then you can pass any variable of the specified type to that sub.

    Either that or change the name in the call to

    Call program(2)

    instead of

    Call iysam(2)

    ...later

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    10
    thank you for the help so far.Right now when i press the start command button it prints

    I
    drink

    I
    am

    Its supose to also print the array after that.But the arrays aren't printing out.What did i do wrong?
    Ummm now how do I do that?

  4. #4
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510
    Change Dim wArray(5) as String
    to
    Public wArray(5) as String

    Then try this in the Sub iysam(Choice!):

    Print "I"

    If choice = 0 Then
    Print "am"
    Print wArray(Choice!)
    Else
    Print "drink"
    Print wArray(Choice!)
    End If

    End Sub

    .......later

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    10
    nope it gets a error with -Public wArray(5) as String

    Ummm now how do I do that?

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    10
    printing arrays is pretty hard
    Ummm now how do I do that?

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