Hi guys!
I have a text file that I want to extract information from. I'd like to get the quantity and the product name information and save it on a 2D array, here's my code:
Below are values displayed for the CLng(Split(quantity_current_all, ";")(I)) and CStr(Split(product_current_all, ";")(I)).
100000030 DISCOTRINE5mg/24h Disp tr B/30
18 HEMIGOXINE NATIV0,125mg Cpr B/30
12 PREVISCAN20mg Cpr B/30
8 DIGOXINE0,25mg-Cpr-B/30
9 PERMIXON160mg Gél B/60
7 SOLIAN200mg Cpr séc B/30
16 VOGALENE LYOC7,5mg Lyoph or B/16
24 AMLOR=AMLOPIDINE10mg Gél B/30
10 BETADINE TULLEPans B/10/10x10
20 DISCOTRINE10mg/24h Disp tr B/30
7 CHIBRO-PROSCAR5mg Cpr pell B/28
5 KARDEGIC160mg Pdr or 30sach
1 ELISOR20mg Cpr séc B/28
But when I try to see the values for temp_current(I, 1) and temp_current(I, 2), no values are displayed.
Do you guys have an idea why I was not able to save the values on the 2D array? I've used redim to declare the length of the array as variable..
Thanks a lot!
I have a text file that I want to extract information from. I'd like to get the quantity and the product name information and save it on a 2D array, here's my code:
Code:
Dim temp_current() As String
ReDim temp_current(1 To number_lines, 1 To 2) As String
Open FileName(a, c, b) For Input As #1 'opens the sales file for the current month
row_number = 0
number_lines = 0
Do Until EOF(1) 'reads the text line per line until the end of file
Line Input #1, LineFromFile
quantity_current = Mid(LineFromFile, 237, 10) 'gets the quantity
product_current = Mid(LineFromFile, 104, 80) 'gets the product name
quantity_current_all = quantity_current_all & quantity_current & ";" 'stores the values of the quantity
product_current_all = product_current_all & product_current & ";" 'stores the values of the produc names
number_lines = number_lines + 1
row_number = row_number + 1
Loop
Close #1
'[B]Save values on 1 2D array[/B]
For I = 1 To number_lines
temp_current(I, 1) = CLng(Split(quantity_current_all, ";")(I))
temp_current(I, 2) = CStr(Split(product_current_all, ";")(I))
Debug.Print CLng(Split(quantity_current_all, ";")(I)), CStr(Split(product_current_all, ";")(I))
Next I
Below are values displayed for the CLng(Split(quantity_current_all, ";")(I)) and CStr(Split(product_current_all, ";")(I)).
100000030 DISCOTRINE5mg/24h Disp tr B/30
18 HEMIGOXINE NATIV0,125mg Cpr B/30
12 PREVISCAN20mg Cpr B/30
8 DIGOXINE0,25mg-Cpr-B/30
9 PERMIXON160mg Gél B/60
7 SOLIAN200mg Cpr séc B/30
16 VOGALENE LYOC7,5mg Lyoph or B/16
24 AMLOR=AMLOPIDINE10mg Gél B/30
10 BETADINE TULLEPans B/10/10x10
20 DISCOTRINE10mg/24h Disp tr B/30
7 CHIBRO-PROSCAR5mg Cpr pell B/28
5 KARDEGIC160mg Pdr or 30sach
1 ELISOR20mg Cpr séc B/28
But when I try to see the values for temp_current(I, 1) and temp_current(I, 2), no values are displayed.
Do you guys have an idea why I was not able to save the values on the 2D array? I've used redim to declare the length of the array as variable..
Thanks a lot!
Last edited: