Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

vb6 array textbox help

  • 16-03-2006 12:44PM
    #1
    Closed Accounts Posts: 65 ✭✭


    hi lads

    can anybody help me please with a problem i am trying to figure out for awhile now. ok first of all i am using vb6, i have an array of command buttons like so:

    command1(0) command1(1) command1(2) command1(3)
    command1(4) command1(5) command1(6) command1(7)
    command1(8) command1(9) command1(10) command1(11)

    when i click on command1() i want button_pressed =1 ......command1(11) button_pressed =12, i then need these values to be put into a textbox as an array of charachers corresponding to the command buttons that were pressed, so if i clicked all of the 12 commands one after the other, the textbox would display 1 2 3 4 5 6 7 8 9 10 11 12, and the final aim for me is to send this down to the serial port.

    I have tried many times to get this to work, can anybody help me with my code??

    Dim button_number as integer

    Private Sub Command1_Click(Index As Integer)
    Select Case Index
    Case 0
    button_number = 1
    .
    .
    .
    .
    Case 11
    button_number = 12
    End Select
    End Sub

    This next bit is where i am having the most trouble

    Text1.Text = Val(Command1.Count)

    so if i click all of the buttons the text box will display them one after the other rather than over-write

    1 2 3 4 5 6 7 8 9 10 11 12


    MSCOMM1.Output = "B" & Text1.Text 'The letter B is sent and is always first as it is being used as a start bit

    Thank you in advance


Comments

  • Closed Accounts Posts: 24 Phileas Fogg


    try
    Private Sub Command1_Click(Index As Integer)
    
        Text1.Text = Text1.Text & " " & cstr(Index)
    
    end sub
    
    


  • Closed Accounts Posts: 54 ✭✭charlo_b


    Private Sub Command1_Click(Index As Integer)
    
        Text1.Text = Text1.Text & " " & cstr([B]Index + 1[/B])
    
    end sub
    
    'Event for sending data to the serial port
    Private Sub cmdSend_Click()               
    
        MSCOMM1.Settings = "9600,n,8,1"         'Making an assumption here
        MSCOMM1.CommPort = 1                             'Another assumption
        MSCOMM1.PortOpen = True
        MSCOMM1.Output = "B" & Text1.Text
        MSCOMM1.PortOpen = False
    
    End Sub
    
    

    What if they are pressed in random order......do they have to be sent sorted?
    Also why not use the standard convention of <stx>data<etx> when sending the data down the serial line? <stx> = chr(2) <etx> = chr(3)


  • Closed Accounts Posts: 65 ✭✭katiepwr


    thank you for your help

    i have never used

    <stx>data<etx> is it easy to use?

    i think i would need to send them out in order because i need to write a c code array to pick up the values on the other end.

    Can i just ask one more question with regards my command button program. All together i will have 16 command buttons which is a 4 by 4 matrix.
    i will call the command buttons (0,0) (0,1)......etc

    i have 4 available options, say the options are 1 2 3 & 4

    when I click on a command button say (0 0 ) i get a prompt asking which option to choose, i pick option 2

    i then need option 2 to be read into the first command button which is (0 0)

    Each of my buttons must have an option assigned to it.

    I have this working with my options and buttons, but what i need help doing is outputs this to the serial??

    My idea (although it may not be the best) is to have a text box of lenght 16, and when i click on a command button and option, the option number knows where to go in the text box.

    I am sorry for being so vague but i am finding it hard to explain

    i know that i can use a flexgrid but how will i compile a flexgrid to a form that the serial will understand and then can be picked up by a c program

    If anybody has any suggests i would be very gratefull


  • Closed Accounts Posts: 899 ✭✭✭Gegerty


    katiepwr wrote:
    thank you for your help

    i have never used

    <stx>data<etx> is it easy to use?

    i think i would need to send them out in order because i need to write a c code array to pick up the values on the other end.

    Can i just ask one more question with regards my command button program. All together i will have 16 command buttons which is a 4 by 4 matrix.
    i will call the command buttons (0,0) (0,1)......etc

    i have 4 available options, say the options are 1 2 3 & 4

    when I click on a command button say (0 0 ) i get a prompt asking which option to choose, i pick option 2

    i then need option 2 to be read into the first command button which is (0 0)

    Each of my buttons must have an option assigned to it.

    I have this working with my options and buttons, but what i need help doing is outputs this to the serial??

    My idea (although it may not be the best) is to have a text box of lenght 16, and when i click on a command button and option, the option number knows where to go in the text box.

    I am sorry for being so vague but i am finding it hard to explain

    i know that i can use a flexgrid but how will i compile a flexgrid to a form that the serial will understand and then can be picked up by a c program

    If anybody has any suggests i would be very gratefull


    Send your output into an xml file, which can be read by any language.


  • Closed Accounts Posts: 54 ✭✭charlo_b


    Your going to have to be less vague.
    I don't really understand what is required.

    The requirements also seem to have changed from the original post!


  • Advertisement
Advertisement