BryanKipp
asked on
Load Column Data into a ComboBox from a .csv file
I have a .CSV file that has 5 columns. I want to populate a ComboBox with just the first "Column" data. I am using the following code:
Private Sub Display_AnimationStart()
Dim strHeadings, strContent() As String
Dim iCtr As Integer
Open "C:\RSLogix 5000\Projects\ArrayTags.cs v" For Input As #1
Line Input #1, strHeadings
Close #1
strContent = Split(strHeadings, ";")
For iCtr = 0 To UBound(strContent)
Pen1_ComboBox.AddItem strContent(iCtr)
Next
On Error Resume Next
For iCtr = 0 To UBound(strContent)
Pen1_ComboBox.AddItem strContent(iCtr)
Next
On Error GoTo 0
End Sub
This appears to open the file, but loads the combobox with the data in the first row of the file two times rather than loading just the items in the first column.
The file data is:
Annapolis Hill Discharge Pressure;AH_DISCHARGE_PRES SURE;PSI;0 ;500
Annapolis Hill Suction Pressure;AH_SUCTION_PRESSU RE;PSI;0;5 00
Annapolis Hill Tank Level;AH_TANK_LEVEL;FT;-25 ;-5
Backwash Flow Control Valve Position;BKWASH_FCV_POS_IN ;Percent;0 ;100
Backwash Flow;BKWASH_FLOW;GPM;0;250
Backwash Flow Set Point;BKWASH_FLOW_SP;GPM;0 ;250
Chaffee Hill Discharge Pressure;CH_DISCHARGE_PRES SURE;PSI;0 ;500
Chaffee Hill Suction Pressure;CH_SUCTION_PRESSU RE;PSI;0;5 00
Chaffee Hill Tank Level;CH_TANK_LEVEL;FT;-25 ;-5
Clear Well Level 1;CLEARWELL1_LEVEL;FT;0;10
Clear Well Level 2;CLEARWELL2_LEVEL;FT;0;10
Clear Well Level 3;CLEARWELL3_LEVEL;FT;0;10
What I am looking for is to have the combobox poulated with everything in the first column.
Thanks
Private Sub Display_AnimationStart()
Dim strHeadings, strContent() As String
Dim iCtr As Integer
Open "C:\RSLogix 5000\Projects\ArrayTags.cs
Line Input #1, strHeadings
Close #1
strContent = Split(strHeadings, ";")
For iCtr = 0 To UBound(strContent)
Pen1_ComboBox.AddItem strContent(iCtr)
Next
On Error Resume Next
For iCtr = 0 To UBound(strContent)
Pen1_ComboBox.AddItem strContent(iCtr)
Next
On Error GoTo 0
End Sub
This appears to open the file, but loads the combobox with the data in the first row of the file two times rather than loading just the items in the first column.
The file data is:
Annapolis Hill Discharge Pressure;AH_DISCHARGE_PRES
Annapolis Hill Suction Pressure;AH_SUCTION_PRESSU
Annapolis Hill Tank Level;AH_TANK_LEVEL;FT;-25
Backwash Flow Control Valve Position;BKWASH_FCV_POS_IN
Backwash Flow;BKWASH_FLOW;GPM;0;250
Backwash Flow Set Point;BKWASH_FLOW_SP;GPM;0
Chaffee Hill Discharge Pressure;CH_DISCHARGE_PRES
Chaffee Hill Suction Pressure;CH_SUCTION_PRESSU
Chaffee Hill Tank Level;CH_TANK_LEVEL;FT;-25
Clear Well Level 1;CLEARWELL1_LEVEL;FT;0;10
Clear Well Level 2;CLEARWELL2_LEVEL;FT;0;10
Clear Well Level 3;CLEARWELL3_LEVEL;FT;0;10
What I am looking for is to have the combobox poulated with everything in the first column.
Thanks
ASKER
That added all the rest of the data, but I'm still getting one line item in the combo box for every item in the .CSV file.....i. e.
the combobox looks like this
Annapolis Hill Discharge Pressure
AH_DISCHARGE_PRESSURE
PSI
0
500
Annapolis Hill Suction Pressure
AH_SUCTION_PRESSURE
PSI
0
500
....etc.
What I'm looking for is:
Annapolis Hill Discharge Pressure
Annapolis Hill Suction Pressure
....etc.
the combobox looks like this
Annapolis Hill Discharge Pressure
AH_DISCHARGE_PRESSURE
PSI
0
500
Annapolis Hill Suction Pressure
AH_SUCTION_PRESSURE
PSI
0
500
....etc.
What I'm looking for is:
Annapolis Hill Discharge Pressure
Annapolis Hill Suction Pressure
....etc.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks! This solves part one of my problem.....now on to part two.
Open in new window