Using my own dll to my excel code
I have a excel code that reads a text file line by line looking for data and populates a spreadsheet with the data. The code the read the file is vry slow in excel, so I isolated that code in a subroutine and compiled it on VB5 into a dll. I am trying to call the dll routine in my excel code, but I can not get it to work. Is there something special I need to do in the VB5 or the excel 2000 to use my compile routine? This was my call Call Elem_Loads(file, elem#, etype, Num_Cond, f(), condm()) This is the code I was compiling to a dll Sub Elem_Loads It calls a few routines below Option Explicit Public Sub Elem_Loads(file As String, elem#, etype As String, Num_Cond As Integer, ff() As Double, condmx() As Long) Dim S As String Dim I As Integer Dim ccount As Integer Dim J As Integer Dim JJ As Integer Dim JJJ As Integer Dim K As Integer Dim KK As Integer Dim KKK As Integer Dim cond# Dim count As Integer ' Start of Loads collection from file given by name. ccount = 0 Open file For Input As #1 Do Until EOF(1) Line Input #1, S If (InStr(100, S, "SUBCASE") 0) Then cond# = Val(Mid(S, 118, 8)) Line Input #1, S Line Input #1, S If (InStr(1, S, "F O R C E S I N B A R") 0) Then Call Bar(S, ccount, etype, elem, cond#, ff(), condmx()) ElseIf (InStr(1, S, "F O R C E S I N B U S H E L E M") 0) Then Call Bush(S, ccount, etype, elem, cond#, ff(), condmx()) ElseIf (InStr(1, S, "F O R C E S I N R O D E L E M") 0) Then Call Rod(S, ccount, etype, elem, cond#, ff(), condmx()) ElseIf (InStr(1, S, "F O R C E S A C T I N G O N S H E A R P A N E L") 0) Then Call Shear(S, ccount, etype, elem, cond#, ff(), condmx()) ElseIf (InStr(1, S, "F O R C E S I N T R I A N G U L A R") 0) Then Call Tri(S, ccount, etype, elem, cond#, ff(), condmx()) Else Line Input #1, S If (InStr(1, S, "F O R C E S I N Q U A D R I L") 0) Then Call Quad(S, ccount, etype, elem, cond#, ff(), condmx()) End If End If End If Loop Num_Cond = ccount Close #1 ' Return the main with etype, conditions and loads End Sub Sub Bar(S, ccount, etype, elem, cond#, ff() As Double, condmx() As Long) Line Input #1, S Line Input #1, S Line Input #1, S Do Until (InStr(1, S, "MSC.NASTRAN") 0) If (Val(Mid(S, 6, 8)) = elem) Then ccount = ccount + 1 etype = "BAR" condmx(ccount) = cond# ff(ccount, 1) = Val(Mid(S, 17, 14)) ff(ccount, 2) = Val(Mid(S, 31, 14)) ff(ccount, 3) = Val(Mid(S, 46, 14)) ff(ccount, 4) = Val(Mid(S, 60, 14)) ff(ccount, 5) = Val(Mid(S, 75, 14)) ff(ccount, 6) = Val(Mid(S, 89, 14)) ff(ccount, 7) = Val(Mid(S, 104, 14)) ff(ccount, 8) = Val(Mid(S, 119, 14)) End If Line Input #1, S Loop End Sub Sub Bush(S, ccount, etype, elem, cond#, ff() As Double, condmx() As Long) Line Input #1, S Line Input #1, S Line Input #1, S Do Until (InStr(1, S, "MSC.NASTRAN") 0) If (Val(Mid(S, 21, 8)) = elem) Then ccount = ccount + 1 etype = "BUSH" condmx(ccount) = cond# ff(ccount, 1) = Val(Mid(S, 33, 14)) ff(ccount, 2) = Val(Mid(S, 47, 14)) ff(ccount, 3) = Val(Mid(S, 61, 14)) ff(ccount, 4) = Val(Mid(S, 75, 14)) ff(ccount, 5) = Val(Mid(S, 89, 14)) ff(ccount, 6) = Val(Mid(S, 103, 14)) ff(ccount, 7) = 0 ff(ccount, 8) = 0 End If Line Input #1, S Loop End Sub Sub Quad(S, ccount, etype, elem, cond#, ff() As Double, condmx() As Long) Line Input #1, S Line Input #1, S Line Input #1, S Line Input #1, S Do Until (InStr(1, S, "MSC.NASTRAN") 0) If (Val(Mid(S, 4, 8)) = elem) Then ccount = ccount + 1 etype = "QUAD" condmx(ccount) = cond# ff(ccount, 1) = Val(Mid(S, 17, 14)) ff(ccount, 2) = Val(Mid(S, 31, 14)) ff(ccount, 3) = Val(Mid(S, 45, 14)) ff(ccount, 4) = Val(Mid(S, 61, 14)) ff(ccount, 5) = Val(Mid(S, 75, 14)) ff(ccount, 6) = Val(Mid(S, 89, 14)) ff(ccount, 7) = Val(Mid(S, 105, 14)) ff(ccount, 8) = Val(Mid(S, 119, 14)) End If Line Input #1, S Loop End Sub Sub Rod(S, ccount, etype, elem, cond#, ff() As Double, condmx() As Long) Line Input #1, S Line Input #1, S Line Input #1, S Do Until (InStr(1, S, "MSC.NASTRAN") 0) If (Val(Mid(S, 7, 8)) = elem) Then ccount = ccount + 1 etype = "ROD" condmx(ccount) = cond# ff(ccount, 1) = Val(Mid(S, 21, 14)) ff(ccount, 2) = Val(Mid(S, 36, 14)) ff(ccount, 3) = 0 ff(ccount, 4) = 0 ff(ccount, 5) = 0 ff(ccount, 6) = 0 ff(ccount, 7) = 0 ff(ccount, 8) = 0 End If If (Val(Mid(S, 67, 8)) = elem) Then ccount = ccount + 1 etype = "ROD" condmx(ccount) = cond# ff(ccount, 1) = Val(Mid(S, 81, 14)) ff(ccount, 2) = Val(Mid(S, 96, 14)) ff(ccount, 3) = 0 ff(ccount, 4) = 0 ff(ccount, 5) = 0 ff(ccount, 6) = 0 ff(ccount, 7) = 0 ff(ccount, 8) = 0 End If Line Input #1, S Loop End Sub Sub Shear(S, ccount, etype, elem, cond#, ff() As Double, condmx() As Long) Line Input #1, S Line Input #1, S Line Input #1, S Line Input #1, S Line Input #1, S Do Until (InStr(1, S, "MSC.NASTRAN") 0) If (Val(Mid(S, 7, 8)) = elem) Then Line Input #1, S ccount = ccount + 1 etype = "SHEAR" condmx(ccount) = cond# ff(ccount, 1) = Val(Mid(S, 36, 13)) ff(ccount, 2) = Val(Mid(S, 64, 13)) ff(ccount, 3) = Val(Mid(S, 92, 13)) ff(ccount, 4) = Val(Mid(S, 120, 13)) ff(ccount, 5) = 0 ff(ccount, 6) = 0 ff(ccount, 7) = 0 ff(ccount, 8) = 0 End If Line Input #1, S Loop End Sub Sub Tri(S, ccount, etype, elem, cond#, ff() As Double, condmx() As Long) Line Input #1, S Line Input #1, S Line Input #1, S Line Input #1, S Do Until (InStr(1, S, "MSC.NASTRAN") 0) If (Val(Mid(S, 4, 8)) = elem) Then ccount = ccount + 1 etype = "TRI" condmx(ccount) = cond# ff(ccount, 1) = Val(Mid(S, 17, 14)) ff(ccount, 2) = Val(Mid(S, 31, 14)) ff(ccount, 3) = Val(Mid(S, 45, 14)) ff(ccount, 4) = Val(Mid(S, 61, 14)) ff(ccount, 5) = Val(Mid(S, 75, 14)) ff(ccount, 6) = Val(Mid(S, 89, 14)) ff(ccount, 7) = Val(Mid(S, 105, 14)) ff(ccount, 8) = Val(Mid(S, 119, 14)) End If Line Input #1, S Loop End Sub -- stressman ------------------------------------------------------------------------ stressman's Profile: http://www.excelforum.com/member.php...o&userid=28139 View this thread: http://www.excelforum.com/showthread...hreadid=480971 |
All times are GMT +1. The time now is 01:14 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com