Excel VBA Funtion parameter input

Joined
May 8, 2013
Messages
1
Reaction score
0
Hi,
I'd like to ask, why is it not working?

Private Sub convert_Click()
Dim sMin, sSec As String
Dim iMin, iSec, iMinSec As Integer

sMin = UserForm2.inpMenit.Value
sSec = UserForm2.inpSec.Value

If sMin = "" Or sSec = "" Then
MsgBox "Please fill all input boxes"
ElseIf IsNumeric(sMin) = False Or IsNumeric(sSec) = False Then
MsgBox "Please input number only"
Else
iMin = CInt(sMin)
iSec = CInt(sSec)
iMinSec = MINSEC(iMin, iSec)
UserForm2.outCnt.Value = iMinSec
End If
End Sub

Public Function MINSEC(inputMin As Integer, inputSec As Integer) As Integer
MINSEC = inputMin * 60 + inputSec
End Function


It said there was a type mismatch in "iMinSec = MINSEC(iMin, iSec)". I already used "CInt" to convert string to integer, but still not working. When I tried to replace iMin, iSec with some integer, it worked.

Thanks for your help.:bow:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top