Results 1 to 5 of 5

Thread: Passing vals by refrence

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    Where am I going wrong? I want bool to pass to sub but I get a "by refrence type mismatch" error.Here's the code:


    Public bool as boolean
    Private Sub Option1_Click(index As Integer)

    If index = 0 Then
    Call Pass(bool)
    If bool = True Then
    frmbool.Show
    End If
    End If
    If index = 1 Then
    Call Pass(bool)
    If bool = True Then
    frmNew.Show
    End If
    End If
    End Sub

    Public Sub Pass(bool As Boolean)
    If InputBox("Please Enter Your Password") = "password" Then
    bool = True
    Unload Me
    Else
    Exit Sub 'Form_Load
    End If
    End Sub

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    if bool is public then why do you need to pass it to the sub? you can assign it a value any where.
    Iain, thats with an i by the way!

  3. #3
    Lively Member
    Join Date
    Mar 2000
    Location
    Fort Lauderdale, FL USA
    Posts
    112
    I ran your code and it worked fine for me.
    Damonous

  4. #4
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Just tries running the code as well. Works fine.
    Iain, thats with an i by the way!

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I would use a function instead of sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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