trippbrown Posted October 30, 2003 Posted October 30, 2003 (edited) Solved Edited October 30, 2003 by trippbrown Quote
russgreen Posted December 3, 2003 Posted December 3, 2003 Was yours anything like this? Public Function PopulateComboFromFile(ByVal ListControl As ComboBox, ByVal FullPath As String, _ ByVal Blank As Boolean, Optional ByVal Delimiter As String = vbCrLf) As Boolean Dim objFso As New Scripting.FileSystemObject() Dim objTextStream As Scripting.TextStream Dim strContents As String Dim arrContents() As String Dim lCtr As Long, lCount As Long Try 'Ensure file exists If Dir(FullPath) = "" Then MsgBox("The file " & FullPath & " does not exist", MsgBoxStyle.OKOnly, "Load contract lists") Exit Function End If 'Get file contents objTextStream = objFso.OpenTextFile(FullPath, Scripting.IOMode.ForReading) strContents = objTextStream.ReadAll objTextStream.Close() 'Split file contents based on delimiter arrContents = Split(strContents, Delimiter) lCount = UBound(arrContents) ListControl.Items.Clear() 'Clear List Control. ListControl.Items.AddRange(arrContents) 'Populate list control If Blank = True Then ListControl.Items.AddRange(New Object() {" "}) 'add blank rows to each combo End If PopulateComboFromFile = True Catch ex As Exception objTextStream = Nothing objFso = Nothing MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Load contract lists") End Try End Function Quote Learn Visual Studio .Net My Homepage
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.