Hi, ik ben een beginnend VB6-programmeur en schrijf een appl. om mijn boeken te beheren. Daarin houd ik in een tabel ook de uitgevers bij.
Met de API call Sendmessage zoek ik vervolgens naar een bepaalde publisher. In de ontwikkelomgeving werkt het prima maar in het .EXE bestand krijg ik de volgende foutmelding: Error message 5 - Invalid procedure call or argument. Hoe kan ik dit oplossen. Hieronder is (een deel van) de code:
Alvast bedankt
Tjipie
Met de API call Sendmessage zoek ik vervolgens naar een bepaalde publisher. In de ontwikkelomgeving werkt het prima maar in het .EXE bestand krijg ik de volgende foutmelding: Error message 5 - Invalid procedure call or argument. Hoe kan ik dit oplossen. Hieronder is (een deel van) de code:
Code:
Public Declare Function sendMessageByString Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As String) As Long
Public Const LB_SELECTSTRING = &H18C
Case cmdFind '-- Find a specific record
Dim iReturn As Integer
gFindString = ""
With frmFind
.addCaption = "Type Publishers Name to find"
.recordSource = "SELECT Name FROM Publishers ORDER BY Name"
.Show vbModal
End With
If (Len(gFindString) > 0) Then
With Data1.Recordset
.FindFirst "Name = '" & gFindString & "' "
If (.NoMatch) Then
iReturn = MsgBox("Publisher Name " & gFindString & _
" was not found.", vbCritical, "Publishers")
Else
iReturn = MsgBox("Publisher Name " & gFindString & _
" was retrieved.", vbInformation, "Publishers")
End If
End With
End If
Private Sub List1_DblClick()
'get the item the user clicks on and assign it
If (InStr(List1, "'")) Then
gFindString = SrchReplace(List1)
Else
gFindString = List1
End If
Unload frmFind
End Sub
Private Sub txtFind_Change()
Dim entryNum As Long
Dim txtToFind As String
txtToFind = txtFind.Text
entryNum = sendMessageByString(List1.hwnd, _
LB_SELECTSTRING, 0, txtToFind)
End Sub
Private Function SrchReplace(ByVal sStringToFix As String) As String
Dim iPosition As Integer 'where is the offending char?
Dim sCharToReplace As String 'which char do we want to replace?
Dim sReplaceWith As String 'what should it be replaced with?
Dim sTempString As String 'build the correct returned string
sCharToReplace = "'"
sReplaceWith = "''"
iPosition = InStr(sStringToFix, sCharToReplace)
Do While iPosition <> 0
sTempString = ""
sTempString = sTempString & Left$(sStringToFix, iPosition - 1)
sTempString = sTempString & sReplaceWith
sTempString = sTempString & _
Mid$(sStringToFix, iPosition + 1, Len(sStringToFix))
iPosition = InStr(iPosition + 2, sStringToFix, sCharToReplace)
Loop
SrchReplace = sTempString
End Function
Tjipie
Laatst bewerkt door een moderator: