adding controls at runtime
-
I am using the following code to add two textboxes to the from option explicit private withevent objText as textbox private sub AddTextBox dim i as integer for i = 1 to 2 set objText = controls.add("vb.textbox", "text" & i) next i end sub private sub objText_Gotfocus() objtext.selstart = 0 objtext.sellengh = len(objtext.text) end sub I add two textboxes to the form using the controls.add method first time set objText = controls.add("vb.textbox", "text1") second time set objText = controls.add("vb.textbox", "text2") the first one losses the referenct to objtext events when the second one is set. there must be a way to preserve the setting??? can someone please help!!!! :(( Confusios say "Man who run in front of car get tired, Man who run behind car get exhausted."
-
I am using the following code to add two textboxes to the from option explicit private withevent objText as textbox private sub AddTextBox dim i as integer for i = 1 to 2 set objText = controls.add("vb.textbox", "text" & i) next i end sub private sub objText_Gotfocus() objtext.selstart = 0 objtext.sellengh = len(objtext.text) end sub I add two textboxes to the form using the controls.add method first time set objText = controls.add("vb.textbox", "text1") second time set objText = controls.add("vb.textbox", "text2") the first one losses the referenct to objtext events when the second one is set. there must be a way to preserve the setting??? can someone please help!!!! :(( Confusios say "Man who run in front of car get tired, Man who run behind car get exhausted."
My VB skills are a little dusty but I think you need to declare two seperate variables objText and objText2, otherwise you only really have one "control". Michael :-)
-
I am using the following code to add two textboxes to the from option explicit private withevent objText as textbox private sub AddTextBox dim i as integer for i = 1 to 2 set objText = controls.add("vb.textbox", "text" & i) next i end sub private sub objText_Gotfocus() objtext.selstart = 0 objtext.sellengh = len(objtext.text) end sub I add two textboxes to the form using the controls.add method first time set objText = controls.add("vb.textbox", "text1") second time set objText = controls.add("vb.textbox", "text2") the first one losses the referenct to objtext events when the second one is set. there must be a way to preserve the setting??? can someone please help!!!! :(( Confusios say "Man who run in front of car get tired, Man who run behind car get exhausted."
-
I am using the following code to add two textboxes to the from option explicit private withevent objText as textbox private sub AddTextBox dim i as integer for i = 1 to 2 set objText = controls.add("vb.textbox", "text" & i) next i end sub private sub objText_Gotfocus() objtext.selstart = 0 objtext.sellengh = len(objtext.text) end sub I add two textboxes to the form using the controls.add method first time set objText = controls.add("vb.textbox", "text1") second time set objText = controls.add("vb.textbox", "text2") the first one losses the referenct to objtext events when the second one is set. there must be a way to preserve the setting??? can someone please help!!!! :(( Confusios say "Man who run in front of car get tired, Man who run behind car get exhausted."
I've never used this method befor, but it seems cool. Try this code it may help you: private sub text1_Gotfocus() text1.selstart = 0 text1.sellengh = len(text1.text) end sub private sub text2_Gotfocus() text2.selstart = 0 text2.sellengh = len(text2.text) end sub