Okay, this is going to be remedial for most of you. I have a combobox which needed to be associated with both a code(varchar) and the display name (varchar). So I made a new class:
I use the same comboboxes for multiple questions (the app is a survey showing one question at a time) so I made a variable to hold their choice once they move to the next question
Then when the comboboxes were filled from a database I used:
Now when they got to the combobox and hit "Next Question" I would simply save that cmboObject:
This above code works great. However, once the survey is submitted, I need to clear all of the variables to get ready for the next person taking the survey. I have tried everything to reset brochureMake1 and brochureMake2 to emptiness (tries = "", = nothing, etc) but keep getting "NullCastException". I am thinking I need to make a "set" function and just set name and code to "" but I cannot get it right. Any suggestions?
Jenn
Code:
public class cmboObject
public _name as string
public _code as string
public sub new(byval name as string, byval code as string)
_name = name
_code = code
end sub
public readonly property Name() as string
get
return _name
end get
end property
public readonly property Code() as string
get
return _code
end get
end property
public overrides function ToString() as string
return name
end function
end class
I use the same comboboxes for multiple questions (the app is a survey showing one question at a time) so I made a variable to hold their choice once they move to the next question
Code:
Dim brochureMake1 as cmboObject
Dim brochureMake2 as cmboObject
Then when the comboboxes were filled from a database I used:
Code:
Dim cmboObjHolder as cmboObject
while dtr.read()
cmboObjHolder = new cmboObject(dtr("field1"), dtr("field2"))
cmboMake1.Items.Add(cmboObjHolder)
end while
Now when they got to the combobox and hit "Next Question" I would simply save that cmboObject:
Code:
brochureMake1 = cmboMake1.SelectedItem
This above code works great. However, once the survey is submitted, I need to clear all of the variables to get ready for the next person taking the survey. I have tried everything to reset brochureMake1 and brochureMake2 to emptiness (tries = "", = nothing, etc) but keep getting "NullCastException". I am thinking I need to make a "set" function and just set name and code to "" but I cannot get it right. Any suggestions?
Jenn