MarcoRome Expert Licensed User Longtime User Feb 29, 2016 #1 Hi i have this code: Code: Copy Dim lst1 As List lst1.Initialize lst1 = su.LoadCSV(directoryname, filename,";") Dim mtp As MyType mtp.Initialize For i = 0 To lst1.Size - 1 Dim sColumn() As String sColumn = lst1.Get(i) Log(sColumn) mtp = lst1.get(i) Log(mtp.description_food) Next Mytype is: Type MyType(id_category_menu As Int , id_details As Int , description_food As String , description_extend As String ,price_small As Double, price_medium As Double, price_large As Double, picture_food As String, currency As String) Click to expand... The File Excel that i load with LoadCSV is this: Now the problem is when i enter in For i see value Log(sColumn ) in correct mode: [0=id_category_menu, 1=id_details, 2=description_food, 3=description_extend , 4=price_small, 5=price_medium, 6=price_large , 7=picture_food, 8=currency] Click to expand... but when run line mtp=lst1.get(i) go in error. Any idea ? Thank you Marco
Hi i have this code: Code: Copy Dim lst1 As List lst1.Initialize lst1 = su.LoadCSV(directoryname, filename,";") Dim mtp As MyType mtp.Initialize For i = 0 To lst1.Size - 1 Dim sColumn() As String sColumn = lst1.Get(i) Log(sColumn) mtp = lst1.get(i) Log(mtp.description_food) Next Mytype is: Type MyType(id_category_menu As Int , id_details As Int , description_food As String , description_extend As String ,price_small As Double, price_medium As Double, price_large As Double, picture_food As String, currency As String) Click to expand... The File Excel that i load with LoadCSV is this: Now the problem is when i enter in For i see value Log(sColumn ) in correct mode: [0=id_category_menu, 1=id_details, 2=description_food, 3=description_extend , 4=price_small, 5=price_medium, 6=price_large , 7=picture_food, 8=currency] Click to expand... but when run line mtp=lst1.get(i) go in error. Any idea ? Thank you Marco
DonManfred Expert Licensed User Longtime User Feb 29, 2016 #2 MarcoRome said: but when run line mtp=lst1.get(i) go in error. Any idea ? Click to expand... You are trying to cast the type to a string array. Code: Copy Dim lst1 As List lst1.Initialize lst1 = su.LoadCSV(directoryname, filename,";") For i = 0 To lst1.Size - 1 Dim mtp As MyType mtp.Initialize mtp = lst1.get(i) Log(mtp.description_food) Next Upvote 0
MarcoRome said: but when run line mtp=lst1.get(i) go in error. Any idea ? Click to expand... You are trying to cast the type to a string array. Code: Copy Dim lst1 As List lst1.Initialize lst1 = su.LoadCSV(directoryname, filename,";") For i = 0 To lst1.Size - 1 Dim mtp As MyType mtp.Initialize mtp = lst1.get(i) Log(mtp.description_food) Next
DonManfred Expert Licensed User Longtime User Feb 29, 2016 #3 I just read your post right... Hmm, loading a csv into a string array will not help you to cast them to your custom type. I think you need to match the string array I think something like Code: Copy Dim lst1 As List lst1.Initialize lst1 = su.LoadCSV(directoryname, filename,";") For i = 0 To lst1.Size - 1 Dim sColumn() As String sColumn = lst1.Get(i) Log(sColumn) Dim mtp As MyType mtp.Initialize mtp.id_category_menu = sColumn(0) mtp.id_details = sColumn(1) mtp.description_food = sColumn(2) mtp.description_extend = sColumn(3) mtp.price_small = sColumn(4) mtp.price_medium = sColumn(5) mtp.price_large = sColumn(6) mtp.picture_food = sColumn(7) mtp.currency = sColumn(8) Log(mtp.description_food) Next Upvote 0
I just read your post right... Hmm, loading a csv into a string array will not help you to cast them to your custom type. I think you need to match the string array I think something like Code: Copy Dim lst1 As List lst1.Initialize lst1 = su.LoadCSV(directoryname, filename,";") For i = 0 To lst1.Size - 1 Dim sColumn() As String sColumn = lst1.Get(i) Log(sColumn) Dim mtp As MyType mtp.Initialize mtp.id_category_menu = sColumn(0) mtp.id_details = sColumn(1) mtp.description_food = sColumn(2) mtp.description_extend = sColumn(3) mtp.price_small = sColumn(4) mtp.price_medium = sColumn(5) mtp.price_large = sColumn(6) mtp.picture_food = sColumn(7) mtp.currency = sColumn(8) Log(mtp.description_food) Next
MarcoRome Expert Licensed User Longtime User Feb 29, 2016 #4 DonManfred said: I just read your post right... Hmm, loading a csv into a string array will not help you to cast them to your custom type. I think you need to match the string array I think something like Code: Copy Dim lst1 As List lst1.Initialize lst1 = su.LoadCSV(directoryname, filename,";") For i = 0 To lst1.Size - 1 Dim sColumn() As String sColumn = lst1.Get(i) Log(sColumn) Dim mtp As MyType mtp.Initialize mtp.id_category_menu = sColumn(0) mtp.id_details = sColumn(1) mtp.description_food = sColumn(2) mtp.description_extend = sColumn(3) mtp.price_small = sColumn(4) mtp.price_medium = sColumn(5) mtp.price_large = sColumn(6) mtp.picture_food = sColumn(7) mtp.currency = sColumn(8) Log(mtp.description_food) Next Click to expand... Right Don, right Upvote 0
DonManfred said: I just read your post right... Hmm, loading a csv into a string array will not help you to cast them to your custom type. I think you need to match the string array I think something like Code: Copy Dim lst1 As List lst1.Initialize lst1 = su.LoadCSV(directoryname, filename,";") For i = 0 To lst1.Size - 1 Dim sColumn() As String sColumn = lst1.Get(i) Log(sColumn) Dim mtp As MyType mtp.Initialize mtp.id_category_menu = sColumn(0) mtp.id_details = sColumn(1) mtp.description_food = sColumn(2) mtp.description_extend = sColumn(3) mtp.price_small = sColumn(4) mtp.price_medium = sColumn(5) mtp.price_large = sColumn(6) mtp.picture_food = sColumn(7) mtp.currency = sColumn(8) Log(mtp.description_food) Next Click to expand... Right Don, right