[RESOLVED] message box error
I try to find the filename in the directory by input the filename in the textbox.
But When user don't put the anyting in the text1, I got the message MsgBox "File not found" . I don't want to get the message like this.
I want the message box appear like this MsgBox "please input you filename" . How to do that?
The message box "File not found" only appear when the filename did not found in the directory
If Ret = 0 And ret2 = 0 Then MsgBox "File not found"
Code:
Private Sub Command1_Click() ' search button. When the file name found.It and display it in the listview
Dim tempstr As String, Ret As Long
tempstr = String(MAX_PATH, 0)
'returns 1 when successfull, 0 when failed
Ret = SearchTreeForFile("C:\Project\Data\", Text1.Text + ".shp", tempstr)
If Ret <> 0 Then Call Insertsub(tempstr)
ret2 = SearchTreeForFile("C:\Project\Data\", Text1.Text + ".img", tempstr)
If ret2 <> 0 Then Call Insertsub(tempstr)
If Ret = 0 And ret2 = 0 Then MsgBox "File not found"
End Sub
Code:
Private Sub Insertsub(tempstr As String)
Dim i As Long
Dim sName() As String
Dim sPath As String
sName = Split(tempstr, "\") 'contains File name'
Dim lvItem As ListItem
Set lvItem = ListView1.ListItems.Add(, , sName(UBound(sName)))
lvItem.ListSubItems.Add , , "" & Left$(tempstr, InStr(1, tempstr, Chr$(0)) - 1)
'call the for to remove the filename extension for example lot.shp become lot and use to display the legend
Text2.Text = FileTitleNoExt(sName(UBound(sName)))
'get the path location from searching file
Text3.Text = GetDirFromFile(tempstr)
End Sub