请问如何把这个function用到事件里?function后面的括号应该写些什嘛才能执行?function

sealife24

新手上路
注册
2005-10-23
消息
107
荣誉分数
0
声望点数
0
How can i us my function into the when i clicked on the cmdInchtoCen
button?Thank you in advance

Private Sub cmdInchtoCen_Click()

dblNum = txtNum.Text
lblAnswer.Caption = dblNum & " inches equals " & dblCen & "
centimeters."

End Sub

Function InchtoCen(ByVal dblNum As Double) As Double

Const dblInchtoCen As Double = 2.54
dblCen = dblNum * dblInchtoCen

End Function
 
hey seallife24, i think i got the solution that you are looking for:
Option Explicit
Dim dblCen As Double

Private Sub cmdInchtoCen_Click()
Dim dblNum As Double
dblNum = txtNum.Text

InchtoCen (dblNum)

lblAnswer.Caption = dblNum & " inches equals " & dblCen & " centimeters."

End Sub

Function InchtoCen(ByVal dblNum As Double) As Double

Const dblInchtoCen As Double = 2.54
dblCen = dblNum * dblInchtoCen

End Function

There you go, and good luck with your VB project
 
后退
顶部