vb.net中的动态数组 [英] Dynamic Array in vb.net
问题描述
嗨我有一个带有很多文本框的应用程序来填充来自用户的数据。我现在的目标是创建一个动态数组并使用一个函数来检查输入的数据。如果输入的数据不会通过某些逻辑If (如在日期文本框中,输入的年份将是1867年)将存储在我的动态数组中。我的问题是如何使用我的应用程序变量填充函数中的动态数组以及返回语句将如何在我的应用程序中?< br $> b $ b
objTest.testCode = FrmHeader.txtEOPtestCode.Text ' 这是我的输入
' 在我的函数中
如果 objTest.testCode> ; 100 然后
getvalue进入我的动态数组。
此外,主要原因是最终在我的
之前调用我的功能
Dim objStreamWriter As 新 StreamWriter(My.Settings.PathToShared& \ Test \测试 - Saved.xml)
在保存到我的xml之前获取输入的数据。
您好,
使用以下代码。
私有 功能 ValidateControls() As ArrayList
Dim arrControls As 新 ArrayList
' 循环控制
对于 每个 Cntrl As Control 在 Me .Controls
' 这里我们得到所有类型的控件所以我们需要隔离
' 仅限文本框控件
如果 TypeOf Cntrl TextBox 然后
' 检查您的验证
' 例如值空白然后添加到arraylist
如果 Cntrl.Text = 然后
arrControls.Add(Cntrl)
结束 如果
结束 如果
下一步
返回 arrControls
结束 功能
如有任何疑问,请与我们联系。希望这对你有所帮助。
谢谢。!
使用List而不是Array。更加简单有效。
https:/ /msdn.microsoft.com/en-us/library/6sh2ey19%28v=vs.110%29.aspx [ ^ ]
祝你好运!
Hi i have an application with lot of textboxes to be filled with data from user.My goal for now is to make a dynamic array and with one function to check the inputed data.If the inputed data wont pass some logical "If" (like in date text box the inputed year will be 1867) will be stored in my dynamic array.My question is how to populate the dynamic array in my function with my application variables and how the return statement will be in my application?
With
objTest.testCode = FrmHeader.txtEOPtestCode.Text 'That's my input
'In my function
if objTest.testCode > 100 then
getvalue into my dynamic array.
Also the main reason for this is to finally call my function before my
Dim objStreamWriter As New StreamWriter (My.Settings.PathToShared & "\Test\Test - Saved.xml")
to get the inputed data before saving in my xml.
Hi,
Use below Code.
Private Function ValidateControls() As ArrayList Dim arrControls As New ArrayList 'Looping throgh the Controls For Each Cntrl As Control In Me.Controls 'Here We get all type of controls So we need to isolate 'Textbox controls only If TypeOf Cntrl Is TextBox Then 'Check your validation ' For example value blank then add into arraylist If Cntrl.Text = "" Then arrControls.Add(Cntrl) End If End If Next Return arrControls End Function
Let me know for any query. Hope this is helpful for you.
Thanks.!
Use List instead of Array. Much simpler and efficient.
https://msdn.microsoft.com/en-us/library/6sh2ey19%28v=vs.110%29.aspx[^]
Good luck!
这篇关于vb.net中的动态数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!