VBA字典将TexBox值添加到字典中
我需要一些帮助来循环浏览所有文本框并将值添加到字典中。
目前,我将所有文本框名称添加为字典的键。
Dim dict as New Dictionary
Dim Week as Class1, wID as String
Dim ctrl as Control
For Each ctrl in UserForm1.Controls
If TypeName(ctrl) = "TextBox" Then
wID = ctrl.name
IF dict.exists(wID) = TRUE Then
set Week = class1
else
set week = dict(wID)
dict.add wID, Week
End if
week.field1 = week.field1 + Application.Username
week.field2 = week.field2 + userform1.combox1.value
week.count = week.count + ctrl.Text 'this part i cant get to work, dont have the option for text or value
Set ReadItems = dict
End if
Next ctrl
我想将所有文本框的值传递到一周中。计数,类似于将所有文本框名称添加到WID(键)
如何感谢所有帮助。
谢谢
I need some help on looping through all my textboxes and adding the values to a dictionary.
Currently, I'm adding all textboxes name's as the key the dictionary.
Dim dict as New Dictionary
Dim Week as Class1, wID as String
Dim ctrl as Control
For Each ctrl in UserForm1.Controls
If TypeName(ctrl) = "TextBox" Then
wID = ctrl.name
IF dict.exists(wID) = TRUE Then
set Week = class1
else
set week = dict(wID)
dict.add wID, Week
End if
week.field1 = week.field1 + Application.Username
week.field2 = week.field2 + userform1.combox1.value
week.count = week.count + ctrl.Text 'this part i cant get to work, dont have the option for text or value
Set ReadItems = dict
End if
Next ctrl
I want to pass all the textboxes values in to week.count, similar to how all the textboxes names are added to wID (key)
appreciate all help.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我设法弄清楚了我要做什么。
然后我更改为:
现在,对于每个文本框,输入的值存储在.count的字典中
I managed to figure out what I was trying to do.
which then I changed this bit to be:
now for each textbox the value entered is stored in the dictionary in .count