那么大侠能帮忙看看这个问题~
函数“record”并非在所有代码路径上都返回值。当使用结果时,可能会在运行时发生 null 引用异常。
Public Function record(ByVal nums As Single, ByVal str As String)
tmp = CSng(nums)
tmpt = str
If add = 0 Then
result3.Text = CSng(nums)
TESTVAR = CSng(nums)
End If
If Teststr = "" Then
FomulaList1.Text = str
Teststr = CStr(str)
End If
add = add + 1
tle = True
End Function
[解决办法]
加return ... 吧,要不就用SUB(ByVal nums As Single, ByVal str As String)
[解决办法]
能改变一下思路吗?
看样子你这个好像是 combobox 组件!
比如这样:
Public Class User Private mCode As String Private mName As String Public sub new(byval code as string, byval name as string) mCode = code mName = name end sub Public Property Code() As String Get Return mCode End Get Set(ByVal value As String) mCode = value End Set End Property Public Property Name() As String Get Return mName End Get Set(ByVal value As String) mName = value End Set End Property '将来 ToString 函数 Return 什么,你的下拉框里显示的就是什么; Public Overrides Function ToString() As String Return mCode & " " & mName End FunctionEnd Class'具体添加到 COMBOBOX 时是这样的user1 = new User("01", "张三")user2 = new User("02", "李四")combobox1.items.add(user1)combobox2.items.add(user2)
[解决办法]
你的函数没有定义类型
要在后面加 As Stirng之类的返回类型
然后再函数内部使用Return 返回值 或者 函数名 = 返回值 来返回想要返回的数据