ravcam
Jan 9th, 2000, 02:24 AM
I am stuck on one area in my program!
I am trying to call a sub to do some storing for me! I made the sub in a module but Every time it goes to preform the call it either stops cold at the call statement of the sub function depending on what changes I have made!
Can anyone help me to get this darn thing to work!
MartinLiss
Jan 9th, 2000, 02:42 AM
It may not have stopped, it could be in aloop. Have you tried setting a breakpoint at the call, and then stepping through the execution?
------------------
Marty
ravcam
Jan 9th, 2000, 08:18 AM
Thanks anyway but I soved my problem! It was giving me an "error variable not defined" when I was trying to call the sub so I got rid of option explicit and it worked! Ha can anyone explain this to me?
jritchie
Jan 9th, 2000, 09:27 AM
Ravcam,
Option Explicit means all variables, recordsets, databases, classes etc etc must be defined in your program. Therefore you cannot use say i as a counter without first declaring it as say Private i as Long.
Removing the Option Explicit means you don't have to declared variables but can use them on the fly, (not particularly good practise).
Put in a breakpoint and F8 through your code till you get the unassigned error, then simple declare the variable name as required.
Hoipe this helps. :)
ravcam
Jan 10th, 2000, 03:41 AM
You want to know the funny thing! I did declare all my variables and such but it still gave me that error as soon as it hits the sub part! And when I did declare another variable to use with it and made all nessesary changes it just gave me an error at the first part of the call statement!
Now the real tricky question is "Why after I did everything right does it still give me the error?"!
Aaron Young
Jan 10th, 2000, 03:48 AM
If it's giving you the error "Variable Not Defined" when using Option Explicit then you Must still have a variable in use that you haven't defined.
For more help, post the Code its complaining about.
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com
[This message has been edited by Aaron Young (edited 01-10-2000).]
ravcam
Jan 10th, 2000, 04:08 AM
Ok I am calling the procedure below. I included my general declarations statement so you could all see my variables. Please note that I have very few things labeled! Please do not tell me how important labeling is! Also I may have parts commented so that I can later add another part to my program which has not yet been created!
Public strCalc As String, strSolve(1 To 50) As String
Public intCur As Integer, intCurPos(1 To 50, 1 To 2) As Integer,intCur2 As Integer
Public i As Integer, j As Integer, k As Integer, l As Integer, m As Integer, n As Integer,o As Integer
Right here is where the error pops up!>>>Public Sub Parenthesis()
n = 1
m = 1
i = 0
j = 1
k = 1
l = 1
o = 1
intCur = 0
intCur = 0
strCalc = frmCalc.txtInput.Text
Do
i = i + 1
intCurPos(i, 1) = InStr(intCur + 1, strCalc, "(", vbTextCompare)
intCurPos(i, 2) = InStr(intCur2 + 1, strCalc, ")", vbTextCompare)
intCur = intCurPos(i, 1)
intCur2 = intCurPos(i, 2)
Loop Until intCurPos(i, 1) = 0 And intCurPos(i, 2) = 0
If intCurPos(1, 1) = 0 And intCurPos(1, 2) = 0 Then
strSolve(1) = strCalc
'Call Calculate
End If
Do
If intCurPos(j, 1) = 0 And intCurPos(j, 2) > 0 Then
'Call Error
End If
If intCurPos(j, 2) = 0 And intCurPos(j, 1) > 0 Then
'Call Error
End If
j = j + 1
Loop Until intCurPos(j, 1) = 0 And intCurPos(j, 2) = 0
Do
If intCurPos(o + 1, 1) = 0 Then
strSolve(1) = Mid(strCalc, intCurPos(1, 1), intCurPos(1, 2) - intCurPos(1, 1) + 1)
Else
If intCurPos(m + 1, 1) > intCurPos(m, 2) Then
n = n * 1
Else: n = 0
End If
End If
m = m + 1
Loop Until intCurPos(m + 1, 1) = 0
Do
If n = 1 Then
strSolve(k) = Mid(strCalc, intCurPos(k, 1), (intCurPos(k, 2) - intCurPos(k, 1) + 1))
'k
m = m - 1
End If
If n = 0 Then
m = 0
Do
If intCurPos(k + 1, 1) < intCurPos(k, 2) Then
strSolve(l) = Mid(strCalc, intCurPos(k + 1, 1), (intCurPos(k, 2) - intCurPos(k + 1, 1) + 1))
End If
k = k + 1
l = l + 1
Loop Until intCurPos(k + 1, 1) = 0
End If
Loop Until m = 0
Can anyone tell me why this code works without option explicit and not with it?
[This message has been edited by ravcam (edited 01-10-2000).]
[This message has been edited by ravcam (edited 01-10-2000).]
Aaron Young
Jan 10th, 2000, 04:18 AM
Because you have 3 Undefined Variables;
o, p and intCur2
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com
[This message has been edited by Aaron Young (edited 01-10-2000).]
ravcam
Jan 10th, 2000, 04:59 AM
Ok, I made corections but now it isn't doing what it did before! In other words it was working before and isn't now! Can anyone help me solve this problem?