
正文
vb.net函数定义,vb·net
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
VB.net 定义方法的问题
sub是可以有参数的,但是是没有返回值的。
你可以用function
如
Function add(ByVal a As Integer, ByVal b As Integer)
add = a + b
End Function
a = add(1,1) 这样a = 2
相关问答
Q1: 关于VB.Net 的函数定义问题如下
【转】VB.net是怎样做到的——Handles和WithEvents - ==Sdhjt的窝== - 博客频道 - CSDN.NET
看看这个博客应该可以帮到你。一般定义方法,函数,不需要“Handles abc”这一截
Q2: VB.net环境中,我要编写一个函数,要求返回一个DataSet,请问如何定义这个函数?
Public Function getmastt(aUser As Variant, scustid As Variant, ssaleas As Variant) As ADODB.Recordset
Dim adoRs As New ADODB.Recordset
Dim sTableName(0) As String, sFullName(0) As String, sDsn(0) As String
Dim sWhere As String
Set oGetPath = CreateObject("M2000UTIL.GETPATH")
sTableName(0) = "QCHKAPPCON"
oGetPath.getpath aUser, sTableName(), Null, sFullName(), sDsn()
sWhere = ""
sWhere = sWhere + " and a.custid= '" scustid "' and a.saleas='" ssaleas "'"
sSql = "select * from " sFullName(0) " a where 1=1 " sWhere
sSql = sSql + " order by a.CUSTID"
With adoRs
.CursorLocation = adUseClientBatch
.CursorType = adOpenKeyset
.LockType = adLockBatchOptimistic
.Open sSql, sDsn(0)
End With
Set getmastt = adoRs
Set adoRs = Nothing
End Function
Q3: vb.net 自定义函数 Private Function refresh(ByVal a As String) As String Return a End Function
refresh是vb的关键词,你最好不要用这个名字作为你自定义函数的名字,当然,VB也允许你用Overrides关键词重载这个方法。
Q4: 在vb.net中如何定义staticextern函数
在vb.net中定义staticextern函数:用static声明的局部变量。static是C++中常用的修饰符,它被用来控制变量的存贮方式和可见性。extern,C是使C++能够调用C写作的库文件的一个手段。
Q5: VB.NET自定义函数
很简单,在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






