08-11-2012, 12:07 PM
Join Date: Aug 2012
VB6 retrieving data from Excel.
Hello Everyone. I've done a bit of searching, but haven't really found the answers I'm looking for.
I'm working on a program which will controls the motors on my milling machine.
My question is how do I go about extracting data from an excel sheet and using it to populate text boxes on my form?
It's going to be hard to explain, but bare with me.
I have 5 text boxes:
Text1 = I call my "program line number" default value = 1
Text2 = X + value
Text3 = X - value
Text4 = Y + value
Text5 = Y - value
When I cycle my program it reads text2 then text3 then text4 then text5 then adds 1 to the value in text1 and repeats.
I also have an excel sheet which generates my X - Y data.
column 1 = program line number (1,2,3,4, etc)
column 2 = x + data
column 3 = x - data
column 4 = y + data
column 5 = y - data
What I want to do is:
If text1 = 1 then return data from excel sheet row 1, populate text2 with column 2, text3 with column3, and so on.
(If I were to do this in excel I'd use vlookup.)
When my program loops it automatically adds 1 to the value in text1, so my hope is that once it changes it will update with the new values in text boxes 2 thru 5.
Does this make any sense? I'm so sorry, my explanation sucks but I really appreciate any help.