If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Importing Text
Hi, I need some help importing a tool list from Mastercam. Here is the Text
File # = 1 Type = Center Drill Tool name = 1/8 CENTERDRILL Diameter = 0.125000 Rad. Type = None Cor. rad. = 0.000000 Threads = 0.000000 # = 2 Type = Center Drill Tool name = 1/4 CENTERDRILL Diameter = 0.250000 # = 3 Type = Center Drill Tool name = 1/2 CENTERDRILL Diameter = 0.500000 Cor. rad. = 0.000000 ..............etc, etc, etc I need to go into each "# =" occurrence then import into a table TID, Type, Tool, Diameter 1, Center Drill, 1/8 CENTERDRILL, 0.125000 2, Center Drill, 1/4 CENTERDRILL, 0.250000 3, Center Drill, 1/2 CENTERDRILL, 0.500000 The "Type, Tool, and Diameter" are always the first 3 Lines After the Tool ID: " # = " Thank you all, Bre-x |
#2
|
|||
|
|||
Importing Text
Thanks!!
Dim strFile As String Dim intFile As Integer Dim strInput As String Dim db As Database Dim rs As Recordset strFile = "N:\1CNC\TOOLLST.TXT" intFile = FreeFile Set db = DBEngine(0)(0) Set rs = db.OpenRecordset("tblTool") Open strFile For Input As intFile Do Line Input #intFile, strInput If Left(strInput, 3) = "# =" Then rs.AddNew rs!ToolNumber = Mid(strInput, 4) ElseIf Left(strInput, 4) = "Type" Then rs!ToolType = Mid(strInput, 8) ElseIf Left(strInput, 9) = "Tool name" Then rs!ToolName = Trim(Mid(strInput, 12)) ElseIf Left(strInput, 8) = "Diameter" Then rs!Diameter = Trim(Mid(strInput, 11)) ElseIf Left(strInput, 8) = "Material" Then rs!mat = Trim(Mid(strInput, 11)) rs.Update End If Loop Until EOF(intFile) rs.Close Set rs = Nothing Set db = Nothing |
Thread Tools | |
Display Modes | |
|
|