Whing Dela Cruz
asked on
How to read textbox with multiple lines separated by slushes?
I have a textbox name text1.text. It has a multiple text. Each line are separated with slushes till the last line. here's the data of the textbox;
3356\Paracetamol 500mg\30
123490\Amoxicillin 350mg Cap\25
7685\Cefalexin\90
I want to read the first line each data separated by "\" till the last line. How? Pls...
3356\Paracetamol 500mg\30
123490\Amoxicillin 350mg Cap\25
7685\Cefalexin\90
I want to read the first line each data separated by "\" till the last line. How? Pls...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Does my code suit you? I don't know what you want to do with the data, so I just show it in the Immediate window.
ASKER
GrahamSkan, you got exactly what I need, Thanks a lot.. Could i ask more question? I need more help about the things I've trying to develop. it is textbox to excell. Thru your help i was able develop the code below, but the problem is.. it only save one data, the last data of the textbox...
Private Sub Command1_Click()
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
'Start a new workbook in Excel
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
'Add data to cells of the first worksheet in the new workbook
Set oSheet = oBook.Worksheets(1)
oSheet.range("A1").Value = "Code"
oSheet.range("B1").Value = "Description"
oSheet.range("c1").Value = "Quantity"
oSheet.range("A1:B1:C1").Font.Bold = True
Dim strlines() As String
Dim strItems() As String
Dim l As Integer
Dim I As Integer
strlines = Split(Me.Text1.Text, vbCrLf)
For l = 0 To 2
strItems() = Split(strlines(l), "\")
For I = 0 To 2
Next I
oSheet.range("A2").Value = strItems(0)
oSheet.range("B2").Value = strItems(1)
oSheet.range("C2").Value = strItems(2)
Next l
'Save the Workbook and Quit Excel
oBook.SaveAs "C:\Report.xlsx"
oExcel.Quit
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much... excellent solution...
ASKER
What I mean about read is;
msgbox first line 'read the first line each data separated by "\" and able to loop till the last line.