基本的VB(a)帮助;返回值。
我做了一个简单的助手程序来帮助演示我的问题。请参阅报价。Public Function MakeTen(X As Integer)
' make an int at least ten.
If X >= 10 Then
' how do I return the value?
End
Else
X = 1 + X
MakeTen (X)
End If
End Function
Sub MainProc()
' How do I ask for a value?
' (dialog box is fine but how do I convert the string to an int?)
' ie Userform1.TextBox1.text ...
MakeTen (...)
' now that I have an int at least ten how do I display it in a msgbox.
End Sub
**** Hidden Message *****
Public Function Times10 ( Argument as Integer ) As Integer
Times10= 10 * Argument
End Function
如果返回类型是一个类,那么你必须使用set语句。 这是根据你的评论。或者根据我的理解,至少
Public Function MakeTen(X As Integer) As Integer
' make an int at least ten.
If X >= 10 Then
MakeTen = X
Else
MakeTen = 10
End If
End Function
Sub MainProc()
Dim strValue As String
Dim i As Integer
strValue = InputBox("Please enter an Integer", "theswamp.org", 1)
i = MakeTen(CInt(strValue))
MsgBox i
End Sub
Bwaaa,伟大的奥德赛裁判。 我觉得总是尽可能描述错误控制是很重要的..它让用户不会感到困惑,并使调试变得容易得多。 鲍勃,你的工作充满了乐趣
页:
[1]