HI everyone
i am trying to write POS and Inventory for myself in vb6. I am stuck and gone blank what to do. here is what i want to do.
search database for the stocks.
change the caption of the button ( eg caption of the botton is "COKE 250ml" and i want it to change to "COKE 250ml [30]" now [30] is the number of coke in stock.

Private Function FindButtonName()
    Dim strTest As String
    Dim strArray() As String
    Dim intCount As Integer
    Dim strButtonName As String

    Dim rsDiscriptionFind As ADODB.Recordset
    Set rsDiscriptionFind = New ADODB.Recordset
    rsDiscriptionFind.Open "Stocks", gobjConn, adOpenDynamic, adLockPessimistic

    rsDiscriptionFind.Filter = "Discription='" & strIC & "'"

    strTest = strIC
    strArray = Split(strTest, " ")

    For intCount = LBound(strArray) To UBound(strArray)
       Trim (strArray(intCount))
    Next
    If intCount = "1" Then
        strButtonName = "Cmd" & strArray(0)
    ElseIf intCount = "2" Then
        strButtonName = "Cmd" & strArray(0) & strArray(1)
    ElseIf intCount = "3" Then
        strButtonName = "Cmd" & strArray(0) & strArray(1) & strArray(2)
    ElseIf intCount = "4" Then
        strButtonName = "Cmd" & strArray(0) & strArray(1) & strArray(2) & strArray(3)
    Else
        strButtonName = "Cmd" & strArray(0) & strArray(1) & strArray(2) & strArray(3) & strArray(4)
    End If
   ' "FrmGraphicMenu.'" & strButtonName & .Caption&"'" = "test"   'this is not working
End Function

Private Sub Command7_Click()

    InitializeDB
    Dim rsStChk As New ADODB.Recordset
    Set rsStChk = New ADODB.Recordset
    rsStChk.Open "Stocks", gobjConn, adOpenDynamic, adLockPessimistic

    Dim rsSearchStock As ADODB.Recordset
    Set rsSearchStock = New ADODB.Recordset
    rsSearchStock.Open "Stocks", gobjConn, adOpenDynamic, adLockPessimistic
    Do Until rsSearchStock.EOF = True
        strIC = rsSearchStock!Discription
        MsgBox strIC
        Call FindButtonName
        rsSearchStock.MoveNext
    Loop
End Sub

it is in loop and i want all the buttons get their quantities updated after every sale entery.
thank you in advance

Save yourself now. You know that VB6 support is long gone and since you can get into the Express versions of Visual Studio, why VB6 today?

As to your update, you code that up and fire it off when the event you want happens. As VB6 events are well done on the web, I stop here.

I am writting in vb6 cause i am little use to it for other ver like .net i will have to go through studies again

I changed from VB6 to later in just a few days. It's not very different here.

That's a lot to plow through to "change the caption of the button." Is the issue the button.caption = "something" or you are still learning about events, etc?

PS. Yes I see your line of code "not working" but very few have VB6 running today so be more specific. Is it VB6 yelping at syntax or something else?

let me put it like this i have 10 button ex.
b1
b2
b3 ..... b10
we know the names of the buttons
for example b1.caption = Coke 250ml
when i make a sale it should chk the database for stock and tell me remaing number of coke 250ml
now when the file is in loop we get the string of name but how to call the function usin value of string. that i cant figure out

thank you so much it worked as a charmed.

dim y as control
for each y in controls
    if typeof y is commandbutton then
        if y.name = strbuttonmame then
            y.caption = stric & " [" & rsdiscriptionfind!Qty & "]"
        end if
    end if
next
commented: Good to read you applied the lead and fixed it. +10
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.