Results 1 to 10 of 10

Thread: [RESOLVED] Array of textboxes

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2009
    Posts
    5

    Resolved [RESOLVED] Array of textboxes

    Hi,
    I'm not very expirienced with VB, but most of my dificulties i can resolve with google.This one not. Not sure if it can
    I have a form in which an array of textboxes is placed by code.
    How can i make an event to start when a change is made in ANY of the textboxes?
    I'm using VB6

    something like:

    'get n from user
    for m=1 to n
    'place Txt_array(n)
    next

    Private Sub Txt_array(any)_change()
    'do something
    End Sub

    thank you in advance

  2. #2
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611

    Re: Array of textboxes

    You get a changed event, with the index of the changed textbox
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2009
    Posts
    5

    Re: Array of textboxes

    can you please be a little more specific?

  4. #4
    New Member
    Join Date
    Sep 2009
    Posts
    1

    Re: Array of textboxes

    I have created one form with an array of text box controls. It means for each text box the name is same. In my example it is txtName. Index property of each control is set to 0,1,2, and 3 (since I have only 4 such controls).

    Following event will be fired whenever there is a change in any of the text box. You can know the index of textbox by Index parameter.

    Private Sub txtName_Change(Index As Integer)

    MsgBox "Text in " & Index & " is changed"

    End Sub

    Is it ok?

    All the best

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2009
    Posts
    5

    Re: Array of textboxes

    It doesnt't work.
    Let me be more specific:

    Dim txt_array() as textbox

    'get n= number of textboxes
    redim txt_array (1 to n)
    for 1 to n
    Set Txt_array(n) = Frm_form.Controls.Add("VB.TextBox", "Txt" & n, Frm_Calcul_Retea)
    next n

    now i need the event triggered on the change of any of the textboxes....

    thank you

  6. #6
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Array of textboxes

    I don't have vb6 here so I am doing this from memory... Please amend syntax error if any...

    vb Code:
    1. Private Sub Txt_array_Change(Index As Integer)
    2.     Select Case Index
    3.     '~~> change was made in Txt_array(0)
    4.     Index = 0
    5.    
    6.     '~~> change was made in Txt_array(1)
    7.     Index = 1
    8.    
    9.     '~~> change was made in Txt_array(2)
    10.     Index = 2
    11.        
    12.     '~> And so on
    13.     End Select
    14. End Sub
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2009
    Posts
    5

    Re: Array of textboxes

    on Private Sub Txt_array_Change(Index As Integer)

    i get an "ambigous name detected:Txt_array_Change" compile error

  8. #8
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Array of textboxes

    that's probably because

    Private Sub Txt_array_Change(Index As Integer)

    exists somewhere in your code... you must have copy and pasted the code from here into your code window...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  9. #9

    Thread Starter
    New Member
    Join Date
    Sep 2009
    Posts
    5

    Re: Array of textboxes

    finnaly figured out
    What I had wasn't an array of textboxes, was an array of variables of type textbox , whitch don't have an 'index' proprety (is empty).
    Ok...now it's time to learn to use them
    Thank you very much for your help.

  10. #10
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Array of textboxes

    kool

    If your query is solved then do remember to mark this thread resolved
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width