0

Compile Error: byref argument type mismatch

I will occasionally encounter this error when I do something like: dim foo, doo, coo as string

I've found 1 of 2 ways to solve this error:

  1. Change the data type to variant as in dim foo, doo, coo as variant

  2. Simply putting each on their own line:

    dim foo as string dim doo as string dim coo as string

I've seen this twice, specifically when using these variables as parameters in functions. Is this a known bug? Is there something intrinsic to defining multiple variables on the same line that I'm missing?

Joseph Erickson
  • 938
  • 3
  • 8
  • 24
  • 2
    `Dim foo, doo, coo As String` means that `foo` and `doo` are `Variant`s. – BigBen Mar 17 '22 at 14:26
  • 1
    `Dim foo As String, doo As String, coo As String`. – BigBen Mar 17 '22 at 14:27
  • @BigBen well...that is enlightening. For a very long time, I assumed you could simply define multiple variables on the same line without only one 'as' statement.. Thanks for clarifying. – Joseph Erickson Mar 17 '22 at 14:27

0 Answers0