本文介绍了如何使这个代码更通用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 从Winform我调用模块中的子例程 Public Sub PopulateWithStates(ByVal myform As Contracts,ByVal FieldName As String ) 选择Case FieldName Case" txtST" myform.txtST.Items.Clear() myform.txtST.Items.Add(" CA") myform.txtST.Items.Add(" WA") 结束选择 End Sub 这样可行,但我真正想做的是不必编写一个案例 语句,其中包含每个字段的所有状态有一个不同的名字。我这样做只是因为我知道它会起作用但是我真的很想 传递Sub例程定义中值所涉及的字段名称这样做了/> 但我不知道怎么做。类似 Public Sub PopulateWithStates(ByVal myform As Contracts,ByVal FieldName As FieldObject) MyForm。 FieldObject.Items.clear() myForm.FieldObject.Add(" CA")等..... 有人可以告诉我如何要做到这一点? 解决方案 From a Winform I am calling the sub routine that follows in a module Public Sub PopulateWithStates(ByVal myform As Contracts, ByVal FieldName AsString)Select Case FieldNameCase "txtST"myform.txtST.Items.Clear()myform.txtST.Items.Add("CA")myform.txtST.Items.Add("WA")End SelectEnd Sub This works but what I would really like to do is not have to write a casestatement with all the states for each field that has a different name. Idid it this way only because I knew it would work but I would really like topass the name of the field involved by value in the Sub routine definitionbut I don''t know how. Something like Public Sub PopulateWithStates(ByVal myform As Contracts, ByVal FieldName AsFieldObject) MyForm.FieldObject.Items.clear()myForm.FieldObject.Add("CA") etc..... Could someone advise me on how to do this? 解决方案 这篇关于如何使这个代码更通用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-13 14:52