PDA

Click to See Complete Forum and Search --> : hmmm help me please


Jessie
Nov 9th, 1999, 12:22 PM
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).]

Milleniux
Nov 9th, 1999, 03:15 PM
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.

Aaron Young
Nov 10th, 1999, 02:28 AM
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.


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


Where cboList is the Item and s_TagList(cboList.ListIndex).dblCost is the Cost of that Item.


------------------
Aaron Young
[i]Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net


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

Jessie
Nov 10th, 1999, 07:29 AM
thanks guys things to try later