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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting a 'Type Mismatch' error... 1

Status
Not open for further replies.

PerlIsGood

Programmer
Jan 24, 2002
154
US
..on this block of code:

Code:
ElseIf Config(0) = "Hotel" Then
  For i = 1 To UBound(Config) Step 1
    aryHotel(i-1) = Config(i)
  Next
End If

Perhaps I'm not allowed to evaluation an expression in the array index...? I don't know. The exact error is: "Type Mismatch:'aryHotel'". Any help would be greatly appreciated... Notorious P.I.G.
 
You could try the following, and your evaluation in the index is fine to do.

ElseIf Config(0) = "Hotel" Then
For i = 1 To UBound(Config)-1
aryHotel(i-1) = Config(i)
Next
End If

* You don't need to use Step if incrementing by 1, it defualts to Step 1. "did you just say Minkey?, yes that's what I said."

MrGreed
 
Well, I was able to get the type mismatch to go away and get the code to work. The only thing I changed elsewhere is the Dim aryHotel statement, which for some reason wouldn't let me declare a dynamic array...

Code:
'Code works with this
Dim aryHotel(9)

'But not with this->Subscript Error out of range...
Dim aryHotel()

' Config contains 7 elements
For i = LBound(Config)+1 To UBound(Config)
  aryHotel(i-1) = Config(i)
Next

I'm coding all of this within the Outlook 2k environment, and I've learned (the hard way) how to live with the many quirks I've found in here. But at least it's working now. Thx for the help. Notorious P.I.G.
 
In VB, when you do this :
Code:
Dim aryHotel()
, you declare your array but with no dimensions (just like creating a TABLE in html without TRs and TDs).
To give dimension, use this syntax :
Code:
Redim [preserve] aryHotel(dim1 [,dim2 [,dim3 [, ...]]])
Where :
-
Code:
preserve
is a optionnal keyword that, if provided, keeps the same the content of the array (if no, redim clears all the arrays cells)
-
Code:
dim1 ... dimN
are integer values that define evry dimension of your array. Water is not bad as long as it stays out human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top