调用方法时如何传递maltiple参数。 [英] how to pass maltiple parameters when call a method.

查看:54
本文介绍了调用方法时如何传递maltiple参数。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有更新方法



 公共  Sub 更新( ByVal  cFields  As  对象 ByVal 作为 对象
如果 RsVoucher.Rows.Count = 0 然后 RsVoucher.AddNew()
对于 Counter = LBound(cFields) UBound(cFields)
RsVoucher.Fields(cFields(Counter))=值(计数器)
下一步
如果 CNull(RsVoucher.Rows( 0 )( DocNo), )= 然后 RsVoucher.Rows( 0 )( DocNo)= NextVoucherNo(RsVoucher.Rows( 0 )( TransTypeID),RsVoucher.Rows( 日期))
如果 CNull(RsVoucher.Rows( 0
)( UserID), )= 然后 RsVoucher.Rows( 0 )( UserID)= CurrentUser.UserID
' 如果是CNull(RsVoucher! PaymentDesc)=然后RsVoucher!PaymentDesc =
RsVoucher.Update()
结束 Sub









当我调用此方法我想传递参数,例如





更新((CID,StudentID,Dated,TransTypeID ,叙述,金额),(0,Ado_Student.Recordset!StudentID,Txt_Dated.Text,S2KVoucherType.Fee_Receipt,txt_Remark.Text,txt_Amount.Text))





我该怎么做。

解决方案

尝试类似:

更新(新列表) (Of  String )()来自{_ 
CID,_
StudentID,_
Dated,_
TransTypeID,_
旁白,_
金额 _
},新列表(Of Object )()来自{_
0 ,_
Ado_Student.Recordset!StudentID,_
Txt_Dated.Text,_
S2KVoucherType.Fee_Receipt,_
txt_Remark。文字,_
txt_Amount.Text _
})


你可以使用数组 解决此问题。 

公共 Sub 更新(ByVal cFields() As String,ByVal () As String)

dim我 as 整数


i = 0 ubound(cfiles())

' ...处理值

next


end sub < /跨度>


i have a update method

Public Sub Update(ByVal cFields As Object, ByVal Values As Object)
       If RsVoucher.Rows.Count = 0 Then RsVoucher.AddNew()
       For Counter = LBound(cFields) To UBound(cFields)
           RsVoucher.Fields(cFields(Counter)) = Values(Counter)
       Next
       If CNull(RsVoucher.Rows(0)("DocNo"), "") = "" Then RsVoucher.Rows(0)("DocNo") = NextVoucherNo(RsVoucher.Rows(0)("TransTypeID"), RsVoucher.Rows("Dated"))
       If CNull(RsVoucher.Rows(0)("UserID"), "") = "" Then RsVoucher.Rows(0)("UserID") = CurrentUser.UserID
       'If CNull(RsVoucher!PaymentDesc) = "" Then RsVoucher!PaymentDesc = ""
       RsVoucher.Update()
   End Sub





when i call this method i want to pass parameters like


Update(("CID", "StudentID", "Dated", "TransTypeID", "Narration", "Amount"),(0, Ado_Student.Recordset!StudentID, Txt_Dated.Text, S2KVoucherType.Fee_Receipt, txt_Remark.Text, txt_Amount.Text))


how can i do it.

解决方案

Try something like:

Update(New List(Of String)() From { _
    "CID", _
    "StudentID", _
    "Dated", _
    "TransTypeID", _
    "Narration", _
    "Amount" _
}, New List(Of Object)() From { _
    0, _
    Ado_Student.Recordset!StudentID, _
    Txt_Dated.Text, _
    S2KVoucherType.Fee_Receipt, _
    txt_Remark.Text, _
    txt_Amount.Text _
})


You can use arrays to solve this problem.

Public Sub Update(ByVal cFields() As String, ByVal Values() As String)

dim I as Integer


for i = 0 to ubound(cfiles())

'...process the values

next


end sub


这篇关于调用方法时如何传递maltiple参数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆