Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetString Type Mismatch

Status
Not open for further replies.

scottian

Programmer
Jul 3, 2003
955
GB
Ive got an error which i cant figure out.

whenever i run my macro i get this error - Type mismatch

these lines are included in a loop -
Dim Acc_Count as integer
Dim Multi_Acc as integer
do while Acc_Count < 12
Multi_Acc = 6
Acc_Count = Trim(Sess0.Screen.GetString(Multi_Acc,3,1))
Multi_Acc = Multi_Acc + 1
Acc_Count = Acc_Count + 1

both 'Acc_Count and Multi_Acc are defined as numbers, the wierd thing is that the code performs the first pass without a problem, its when it performs the second pass when i get the error.

Can anyone help

"Children are smarter than any of us. Know how I know that? I don't know one child with a full time job and children."...Bill Hicks
 
scottian,

Do you have a "loop" statement at the end of that code?

-LB

 
Sorry missed that of the post.

Yes there is a loop statement at the end.

I also put in a load of msgboxes so i could see what was happening, it did manage to loop and the error ended up on this line
Acc_Count = Trim(Sess0.Screen.GetString(Multi_Acc,3,1))

"Children are smarter than any of us. Know how I know that? I don't know one child with a full time job and children."...Bill Hicks
 
Don't know why it would work the first time around but....

Have you tried:

Acc_Count = Val(Trim(Sess0.Screen.GetString(Multi_Acc,3,1)))

I'm not a techie but thats what I would try.

Good Luck
 
Tesco is correct .GetString returns a string and you are trying to set the integer ACC_Count to a string variable. Since your already dimmed as an integer i'd recommend using the Int() function as opposed to the val() function.

e.x.

Acc_Count = INT(Trim(Sess0.Screen.GetString(Multi_Acc,3,1)))




[small]Sometimes you gotta leave your zone of safety. You have to manufacture Inspirado. You gotta get out of the apartment. You've got to run with the wolves. You've got to dive into the ocean and fight with the sharks. Or just treat yourself to a delicious hot fudge sundae........ with nuts. - Jack Black[/small]
 
I'd recommend using IsNumeric too...
If IsNumeric(Sess0.Screen.GetString(Multi_Acc,3,1)) Then
Acc_Count = INT(Trim(Sess0.Screen.GetString(Multi_Acc,3,1)))
Else
'Coding to handle pulling bad data.
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top