Results 1 to 4 of 4

Thread: hmmm help me please

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Location
    Calgary,Alberta, Canada
    Posts
    70

    Post

    ok lets see if i can word this correctly
    enough to make sense
    lets say i have a list of stuff in a flat file eg
    bread|2.50
    milk|1.50
    cheese|4.50
    now i declared a array with this
    type TagStuff
    strStuff as string
    dblCost as double
    end type
    public S_taglist() as TagStuff

    I then only load the first part of the array
    into a combolist box that i have done ok no problems.Then when i select the text in the combo box it has to go to a flexgrid with two colums one for the strSuff and another
    for dblCost i not sure how to load the dblCost part of the array into the second columm so that when the text is added to the
    gird the PROPER cost of the item is added also
    Private Sub cmdAddList_Click()
    If cboList.Text = "" Then Exit Sub

    grdItemSelect.Col = 1
    grdItemSelect.Row = intstuffCount + 1
    grdItemSelect.Text = cboList.Text
    grditemSelect.Col = 2
    grdItemselect.Text=????
    intStuffCount = intStuffCount + 1
    grdMovieSelect.Rows = intStuffCount + 2


    cboListText = ""


    End
    so I'am not sure how to reference these together Please help me I am a newbie to VB


    [This message has been edited by Jessie (edited 11-10-1999).]

  2. #2
    Junior Member
    Join Date
    Nov 1999
    Location
    Liskeard, cornwall
    Posts
    21

    Post

    Jessie

    When clicking on the item in the combo-drop-down, you want to be able to insert the price into a flex grid? Looking at a flat file is probably not the best way to do this but here goes. I would allocate a variable equal to the value of combo.text (the item selected) and then search for that item in your flat file. something like...

    Private Sub Combo1_Click()
    holditem=combo1.text
    open {flat-file} for input as #1
    do while not EOF (1)
    input #1, file_line
    ans=instr(1,holditem,file_line,1)
    if ans<>0 then
    hold_line=file_line
    endif
    loop
    close #1

    'from here do a search for "|" in that line

    findl=instr(1,"|",hold_line,1)
    if findl<>0 then
    length1=len(hold_line)
    itemprice=mid(holdline,findl+1,length1)
    else
    msgbox("Somethings Wrong")
    endif

    'the above statement looks for the "|" and
    'pulls the price out of the variable.
    'this price is held in a var called itemprice
    'from here you will have your item+price in
    'two seperate places.
    'holditem+itemprice.
    End Sub

    You may need to change this code a bit as I have typed it directly into this reply box and have not tested it, but the principle is the same

    good luck

    M.

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    It would be alot easier, (and you wouldn't need to keep accessing the file), if you use the ListIndex Property of the Combobox to get the Cost from your Array that you've already loaded the Values into, eg.

    Code:
    Private Sub cmdAddList_Click()
        If ListIndex<0 Then Exit Sub
        'You Can Add More Than One Column At a Time using Chr(9) 'Tab' As a Seperator
        grdItemSelect.AddItem cboList & Chr(9) & s_TagList(cboList.ListIndex).dblCost
    End Sub
    [i]Where cboList is the Item and s_TagList(cboList.ListIndex).dblCost is the Cost of that Item.


    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


    [This message has been edited by Aaron Young (edited 11-10-1999).]

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Location
    Calgary,Alberta, Canada
    Posts
    70

    Post

    thanks guys things to try later

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