ByRef Argument Type Mismatch help
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: ByRef Argument Type Mismatch help

  1. #1
    Join Date
    Dec 2011
    Posts
    3

    ByRef Argument Type Mismatch help

    I have inherited a program that needs work. I have been staring at this for days, and am missing the answer. I am getting a ByRef Argument Type Mismatch when I compile:

    Public Sub LoadShifts()
    Dim tb As Recordset
    Dim cString As String
    If lstRank.Text = "<ALL>" Then
    Set tb = DB.OpenRecordset("Select Shift,Rank,ShiftOneLetter,ID From Shifts" & _
    " Where IsNumeric(Shift) Order By Shift")
    Else
    Set tb = DB.OpenRecordset("Select Shift,Rank,ShiftOneLetter,ID From Shifts " & _
    "Where IsNumeric(Shift) And " & _
    "Rank Like '*" & lstRank.ItemData(lstRank.ListIndex) & _
    "*' Order By Shift")
    End If
    grdShifts.SelectionMode = flexSelectionByRow
    grdShifts.AllowBigSelection = True
    grdShifts.FillStyle = flexFillSingle
    grdShifts.ColWidth(0) = 650
    grdShifts.ColWidth(1) = 975
    grdShifts.ColWidth(2) = 500
    grdShifts.ColAlignment(0) = flexAlignCenterCenter
    grdShifts.ColAlignment(1) = flexAlignLeftCenter
    grdShifts.ColAlignment(2) = flexAlignCenterCenter
    grdShifts.TextMatrix(0, 0) = "Shift"
    grdShifts.TextMatrix(0, 1) = "Rank(s)"
    grdShifts.TextMatrix(0, 2) = "ID"
    PopulateFlexGrid grdShifts, tb
    tb.Close
    End Sub


    What am I missing? Thank you for any help you can provide.

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,981

    Re: ByRef Argument Type Mismatch help

    What am I missing? Thank you for any help you can provide.
    1. Need CODE TAGS (Like QUOTE tags)
    Code:
    ' Like THIS
    2. More Code needs to be shown (see #2)

    3. Mark the line with the error in RED or BOLD

    Thanks!
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Dec 2011
    Posts
    3

    Re: ByRef Argument Type Mismatch help

    Public Sub LoadShifts()
    Dim tb As Recordset
    Dim cString As String
    If lstRank.Text = "<ALL>" Then
    Set tb = DB.OpenRecordset("Select Shift,Rank,ShiftOneLetter,ID From Shifts" & _
    " Where IsNumeric(Shift) Order By Shift")
    Else
    Set tb = DB.OpenRecordset("Select Shift,Rank,ShiftOneLetter,ID From Shifts " & _
    "Where IsNumeric(Shift) And " & _
    "Rank Like '*" & lstRank.ItemData(lstRank.ListIndex) & _
    "*' Order By Shift")
    End If
    grdShifts.SelectionMode = flexSelectionByRow
    grdShifts.AllowBigSelection = True
    grdShifts.FillStyle = flexFillSingle
    grdShifts.ColWidth(0) = 650
    grdShifts.ColWidth(1) = 975
    grdShifts.ColWidth(2) = 500
    grdShifts.ColAlignment(0) = flexAlignCenterCenter
    grdShifts.ColAlignment(1) = flexAlignLeftCenter
    grdShifts.ColAlignment(2) = flexAlignCenterCenter
    grdShifts.TextMatrix(0, 0) = "Shift"
    grdShifts.TextMatrix(0, 1) = "Rank(s)"
    grdShifts.TextMatrix(0, 2) = "ID"
    PopulateFlexGrid grdShifts , tb
    tb.Close
    End Sub

    ------------------
    I copied and pasted exactly what is there...this is the only part that appears to have an error. I hope this helps.

  4. #4
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: ByRef Argument Type Mismatch help

    The cause of the problem seems to be the routine PopulateFlexGrid.
    You should check the definition which is like
    Code:
    Private Sub PopulateFlexGrid(...)
    The error message gives a hint that one of the arguments is possibly not properly declared.
    Please find this procedure and show it to us.

  5. #5
    Join Date
    Dec 2011
    Posts
    3

    Re: ByRef Argument Type Mismatch help

    Quote Originally Posted by WoF View Post
    The cause of the problem seems to be the routine PopulateFlexGrid.
    You should check the definition which is like
    Code:
    Private Sub PopulateFlexGrid(...)
    The error message gives a hint that one of the arguments is possibly not properly declared.
    Please find this procedure and show it to us.
    Public Function PopulateFlexGrid(FlexGrid As Object, _
    rs As Object) As Boolean
    ' On Error GoTo ErrorHandler
    If Not TypeOf FlexGrid Is MSFlexGrid Then Exit Function
    Dim i As Integer
    Dim j As Integer
    FlexGrid.FixedRows = 1
    FlexGrid.FixedCols = 0
    On Error Resume Next
    rs.MoveLast
    rs.MoveFirst
    On Error GoTo ErrorHandler
    FlexGrid.TextMatrix(1, 0) = ""
    FlexGrid.TextMatrix(1, 1) = ""
    If Not rs.EOF Then
    FlexGrid.rows = rs.RecordCount + 1
    FlexGrid.cols = rs.Fields.Count
    i = 1
    Do While Not rs.EOF
    For j = 0 To rs.Fields.Count - 1
    If Not IsNull(rs.Fields(j).value) Then
    FlexGrid.TextMatrix(i, j) = rs.Fields(j).value
    End If
    Next
    i = i + 1
    rs.MoveNext
    Loop
    Else
    FlexGrid.rows = 2
    End If
    PopulateFlexGrid = True
    ErrorHandler:
    Exit Function
    End Function

  6. #6
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: ByRef Argument Type Mismatch help

    Hm, that's strange. Could you please make a screenshot of the error message popup?
    You sure the line
    PopulateFlexGrid grdShifts , tb
    pops up the error?

    A declaration like Public Function PopulateFlexGrid(FlexGrid As Object, rs As Object) As Boolean
    should not provoke an error, because Object can be any object reference.

    And please start using code tags next time you post code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center