Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. adding controls at runtime

adding controls at runtime

Scheduled Pinned Locked Moved Visual Basic
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    markmyb
    wrote on last edited by
    #1

    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."

    M L 3 Replies Last reply
    0
    • M markmyb

      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."

      M Offline
      M Offline
      Michael P Butler
      wrote on last edited by
      #2

      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 :-)

      1 Reply Last reply
      0
      • M markmyb

        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."

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        hahahahahah

        1 Reply Last reply
        0
        • M markmyb

          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."

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups