ByRef argument type mismatch


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: ByRef argument type mismatch

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    ByRef argument type mismatch

    [Originally posted by Alex]

    I have an array of buttons and for this I use

    Public Sub UpdateButtons(Optional blockEm As Variant)
    '
    '
    '
    End Sub

    Public Sub NavigateButtons(sButtonString As String)
    '
    '
    '
    End Sub

    Public Sub LockTheControls(bLocked As Variant) 'Boolean
    Dim iIndx As Integer
    With Screen.ActiveForm
    For iIndx = 0 To .Controls.Count - 1
    ˙ ˙ If (.Controls(iIndx).Tag = "1") Then
    ˙ ˙ ˙ ˙ If (TypeOf .Controls(iIndx) Is TextBox) Then
    ˙ ˙ ˙ ˙ ˙ ˙ If (bLocked) Then
    ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ .Controls(iIndx).Locked = True
    ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ .Controls(iIndx).BackColor = vbWhite
    ˙ ˙ ˙ ˙ ˙ ˙ Else
    ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ .Controls(iIndx).Locked = False
    ˙ ˙ ˙ ˙ ˙ ˙ ˙ ˙ .Controls(iIndx).BackColor = vbYellow
    ˙ ˙ ˙ ˙ ˙ ˙ End If
    ˙ ˙ ˙ ˙  End If
    ˙ ˙  End If
    Next
    End With

    End Sub


    So if I declare parameter bLocked as Boolean

    Public Sub LockTheControls(bLocked As Boolean)

    there is "Compile error: ByRef argument type mismatch"

    But when
    I declare parameter bLocked as Variant
    there is no error

    Why this happen
    Please help me
    If there is any help I appreciate it

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:ByRef argument type mismatch

    [Originally posted by FreeVBCode.com]

    The error is probably in whatever code is calling LockTheControls.˙ You are probably passing a non-boolean value to it.

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:ByRef argument type mismatch

    [Originally posted by Angchuk]

    Since u dodnot return or modifying the value of bLocked in the Public Sub LockTheControls(bLocked As Boolean)
    try declaring like this:


    Public Sub LockTheControls(ByVal bLocked As Boolean)

    OR:

    Check if bLocked is declared as Boolean in the caller function.

    For example if u have declared bLocked˙ like this

    Dim bLocked, exTestBoolean As Boolean 'Where exTestBoolean is an another boolean variable

    The try declaring like this

    Dim bLocked As Boolean, exTestBoolean As Boolean 'Where exTestBoolean is an another boolean variable

    Drop a line if its :-)˙ or even if its :-(


  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:ByRef argument type mismatch

    [Originally posted by Alex]

    O, yes thanks a lot.It was my fault

    I declared as you told me to do now there is no error

    Public Sub LockTheControls(ByVal bLocked As Boolean)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center