很简单,在end select前再多加一种情况case else return "XXXx",因为你只提供了0-9这10种情况
创新互联专注于南华企业网站建设,响应式网站建设,电子商务商城网站建设。南华网站建设公司,为南华等地区提供建站服务。全流程按需定制,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务
Public Function Zuhe(ByVal qa As String) As String
Select Case qa
Case "0"
Return "1"
Case "1"
Return "3"
Case "2"
Return "4"
Case "3"
Return "6"
Case "4"
Return "2"
Case "5"
Return "8"
Case "6"
Return "9"
Case "7"
Return "7"
Case "8"
Return "5"
Case "9"
Return "0"
Case else
Return "XXXX"
End Select
End Function
首先新建一个类库项目,把你的代码以类(需要实例)或模块(静态)的形式封装好,生成过后在输出目录(bin/debug或bin/release)里面会有个项目名.dll文件,就是它了。
在调用方项目里,右键解决方案资源管理器中的引用,添加引用,浏览到你的dll文件。接着到你的代码中,代码最上面写:
Imports 项目名
然后调用这个类或模块即可。
根据你的情况,可能用模块封装更适合一些。比如:
Public Module MatrixSolve
Public Function Solve(para1 As Double,para2 As Double) As Double
'一些代码
Return result
End Function
End Module
调用起来只要这样即可:
Dim num As Double = MatrixSolve.Solve(x,y)
注意模块和函数的访问级别都用Public,否则外面无法访问。
注意:参数为动态数组;
Private Function MyF(ByRef d() As Integer)
ReDim d(4, 13) As Integer
Dim i As Integer
Dim j As Integer
Dim n As Integer
Dim MyNum(4) As Integer
For i = 1 To 4
MyNum(i) = 0
Next i
Randomize
For i = 1 To 4
For j = 1 To 13
n = Int(Rnd * 4 + 1)
Do While MyNum(n) = 13
n = Int(Rnd * 4 + 1)
Loop
d(i, j) = n
MyNum(n) = MyNum(n) + 1
Next j
Next i
End Function