-
Hi,
I have created my own public function to open up a file with a string type argument, and the function should let me know whether the file is open ok by setting the My function as true.
Public fundction Myfunction (filename as string) as Boolean
Well, I found that to use this function to open a file, I tried to pass the filename, I need to use MyFunction("Filename") and it works ok. But when I tried to use string variable to replace the fix file name, it just does not work. Say,
Dim myFileName as string
myFileName = "FileName"
If MyFunction(myFileName) = True then.........
It just ignore this as it never find the right file name.
Could you help ?
Thanks.
-
'this code will work
Public Function callone(s As String) As Boolean
If s = "Hello" Then
callone = True
Else
callone = False
End If
End Function
Private Sub Command1_Click()
If callone(Text1.Text) Then
MsgBox "Correct"
Else
MsgBox "Incorrect"
End If
End Sub
-
In fact my application is trying to read a series of files which has the name with "Filename01", "Filename02"....
I was trying to use the For-Next loop to loop from 1 to N depends of how many files I have. What I did was
For I = 1 to N
strFileName = "FileName0" & str$(I)
and I realize that this probably just give a string of 01, and I may need to pass the argument with "01",
I did this to get that
strFileName = """"strFileName""""
I am not sure this is the right way to do, but I did get the "FileName01", but just did not work if I put down variable strFileName to the Function.
Thanks.
-
n_indureddy,
You are right and. I was wrong, thinking about I need to pass the string with a " " to the function. It is working now without the " ".