lazyuser
02-19-2009, 01:18 PM
i had this code that worked for a list box. i had some text coming out of this list box and getting populated in 4 different
columns in a spreadsheet.
lboReporterType.AddItem xlSheet.Cells(row, col - 1) & " %- " & xlSheet.Cells(row, col) & " %s " & _
xlSheet.Cells(row, col + 1) & " %f " & xlSheet.Cells(row, col + 4) 'Add mulitiple lines into the combobox
however, the requirement now is that i need to display these values in four seperate columns in the listbox. i do not need
to append the delimiters ('%-', '%s' and '%f') here .
i then read the values from the listbox and update an excel spreadsheet as well as a text file (this part is existing
functionality). the code is here:
Dim ff As Long
Dim strBuff As String
Dim strTest As String
Dim strTest1 As String
Dim strTest2 As String
Dim strTest3 As String
Dim strTest4 As String
Dim strTest5 As String
Dim abc As Long
Dim Text As String
ff = FreeFile
If lboReporterType.Text = "" Then
MsgBox "'Reporter Type' cannot be blank. Please enter a value for Sample Cite.", vbOKOnly, appName
End
End If
Open "C:\xxxxx\statrep.db" For Input As #ff
While Not EOF(ff)
Line Input #ff, Text
strBuff = strBuff & Text & " "
Wend
Close #ff
strTest = lboReporterType.Text
abc = InStr(1, strBuff, strTest, vbTextCompare)
If abc <> 0 Then
MsgBox "Code already exists in file.", vbOKOnly, appName
lboReporterType.SetFocus
Exit Sub
Else
Open "C:\xxxxx\statrep.db" For Append As #ff
Print #ff, strTest
Close #ff
MsgBox "The Dictionary file has been appended.", vbOKOnly, appName
End
End If
the question here is:
(1) how would i split the code above to display the text in 4 different columns in the listbox.
(2) how would i update the excel spreadsheet with the four different listbox columns?
thanksss
columns in a spreadsheet.
lboReporterType.AddItem xlSheet.Cells(row, col - 1) & " %- " & xlSheet.Cells(row, col) & " %s " & _
xlSheet.Cells(row, col + 1) & " %f " & xlSheet.Cells(row, col + 4) 'Add mulitiple lines into the combobox
however, the requirement now is that i need to display these values in four seperate columns in the listbox. i do not need
to append the delimiters ('%-', '%s' and '%f') here .
i then read the values from the listbox and update an excel spreadsheet as well as a text file (this part is existing
functionality). the code is here:
Dim ff As Long
Dim strBuff As String
Dim strTest As String
Dim strTest1 As String
Dim strTest2 As String
Dim strTest3 As String
Dim strTest4 As String
Dim strTest5 As String
Dim abc As Long
Dim Text As String
ff = FreeFile
If lboReporterType.Text = "" Then
MsgBox "'Reporter Type' cannot be blank. Please enter a value for Sample Cite.", vbOKOnly, appName
End
End If
Open "C:\xxxxx\statrep.db" For Input As #ff
While Not EOF(ff)
Line Input #ff, Text
strBuff = strBuff & Text & " "
Wend
Close #ff
strTest = lboReporterType.Text
abc = InStr(1, strBuff, strTest, vbTextCompare)
If abc <> 0 Then
MsgBox "Code already exists in file.", vbOKOnly, appName
lboReporterType.SetFocus
Exit Sub
Else
Open "C:\xxxxx\statrep.db" For Append As #ff
Print #ff, strTest
Close #ff
MsgBox "The Dictionary file has been appended.", vbOKOnly, appName
End
End If
the question here is:
(1) how would i split the code above to display the text in 4 different columns in the listbox.
(2) how would i update the excel spreadsheet with the four different listbox columns?
thanksss