khu
04-07-2014, 12:35 PM
I've built a custom class and I'm providing the user a combobox that contains the class methods so they may select the desired output. There are instances of the class stored in a dictionary (nodedata) where I can return data from dictionary(item).method for whatever item, or method in the item class.
I have a userform with 3 comboboxes that identify what to search for: Node Number, Dataset, and Parameter. The syntax for getting an item from the dicitonary is -- nodedata("Node#_dataset").parameter --. The dictionary works fine and I can manually input the what node, dataset and parameter I want to return (i.e. nodedata("node4_scenarioA").x_coord will give me the corresponding data), but when I try and run this through a userform, I'm having issues calling the method. The code below should show a message box with the data the user requested.
With UserForm1
LookUpVal = CStr("node" & .TextBox1.Text & "_" & .ComboBox1.Text) 'creates the "Node#_dataset" format for the dictionary key
parameter = .ComboBox2.value
End With
MsgBox(nodedata(lookupval).parameter)
If I manually put the parameter I want (i.e. x_coord), this would work, but leaving the method as a variable "parameter" is giving me problems. I'm wondering if it has to do with the data type being variant/string, but I'm not sure how to get it into a readable method type. I know that when I call a method in the code window I do not put quotes around .parameter, so I'm assuming this is the hangup.
I'm fairly new to classes as well. Any help is appreciated, thanks.
I have a userform with 3 comboboxes that identify what to search for: Node Number, Dataset, and Parameter. The syntax for getting an item from the dicitonary is -- nodedata("Node#_dataset").parameter --. The dictionary works fine and I can manually input the what node, dataset and parameter I want to return (i.e. nodedata("node4_scenarioA").x_coord will give me the corresponding data), but when I try and run this through a userform, I'm having issues calling the method. The code below should show a message box with the data the user requested.
With UserForm1
LookUpVal = CStr("node" & .TextBox1.Text & "_" & .ComboBox1.Text) 'creates the "Node#_dataset" format for the dictionary key
parameter = .ComboBox2.value
End With
MsgBox(nodedata(lookupval).parameter)
If I manually put the parameter I want (i.e. x_coord), this would work, but leaving the method as a variable "parameter" is giving me problems. I'm wondering if it has to do with the data type being variant/string, but I'm not sure how to get it into a readable method type. I know that when I call a method in the code window I do not put quotes around .parameter, so I'm assuming this is the hangup.
I'm fairly new to classes as well. Any help is appreciated, thanks.