[RESOLVED] Help: Variable not defined
well hi.. i Got this Variable not defined error(durationinms) .. and I cant seem to find a solution for it so :
Code:
Public Function MP3DurationInMs()
On Error GoTo TheError
Dim TotalTime As String * 128
Dim T As String
TheFile$ = Chr$(34) + Trim(MP3File$) + Chr$(34)
mciSendString "set " & TheFile & " time format ms", TotalTime, 128, 0&
mciSendString "status " & TheFile & " length", TotalTime, 128, 0&
mciSendString "set " & TheFile & " time format frames", 0&, 0&, 0&
DurationInMs = Val(TotalTime)
Exit Function
TheError: MsgBox Err.Description, , " Error"
End Function
i was using a MP3 class... added it to my project.. i can test run it .. and all will work.. but the moment i want to compress i get the Variable not defined error.. ..however i thought it IS defined. ? any help lplz :confused:
Re: Help: Variable not defined
Welcome to VBForums :wave:
It isn't defined in your code, but based on the name it appears that is was defined at some point - and since then you have added MP3 to the start of the function name, but didn't update the name on that line.
Re: Help: Variable not defined
In Visual Basic 6 (and below), the the way functions returns values is not the same as other languages. In VB6 We assign the value we want to return to a variable with the same name as the function name.
Code:
Public Function DurationInMs()
'...
DurationInMs = Val(TotalTime) '<-- we are returning the value to function caller
End Function
So the correct thing for what you want might be this.
Code:
Public Function MP3DurationInMs()
'...
MP3DurationInMs = Val(TotalTime) '<-- we are returning the value to function caller
End Function
Re: Help: Variable not defined
Quote:
Originally Posted by Pradeep1210
...In VB6 We assign the value we want to return to a variable with the same name as the function name....
It's not a variable but rather the function itself and the proof of that is that you don't have to Dim it.