I could use some help trying to figure out why I am getting a type mismatch error.
My code:
Public Function GetHit(Digi As Variant, Draw As Variant)
Dim B1 As Variant
Dim B2 As Variant
Dim B3 As Variant
Dim Var1 As Variant
Dim Var2 As Variant
Dim Var3 As Variant
Dim Var4 As Variant
Dim Var5 As Variant
Dim Var6 As Variant
Set B1 = (Left(Draw, 1))
Set B2 = (Left(Right(Draw, 2), 1))
Set B3 = (Right(Draw, 3))
Set Var1 = Trim([B1] & [B2] & [B3])
Set Var2 = Trim([B1] & [B3] & [B2])
Set Var3 = Trim([B2] & [B1] & [B3])
Set Var4 = Trim([B2] & [B3] & [B1])
Set Var5 = Trim([B3] & [B2] & [B1])
Set Var6 = Trim([B3] & [B1] & [B2])
Select Case [Digi]
Case [Var1], [Var2], [Var3], [Var4], [Var5], [Var6]
[GetHit] = "HIT"
Case Else
[GetHit] = ""
End Select
End Function
Althought I try to use TRIM to make the results clearly text it won't work. I originally compiled all my variables to text but then the code would not compile so I made them all variant type.
Any help would be appreciated.
My code:
Public Function GetHit(Digi As Variant, Draw As Variant)
Dim B1 As Variant
Dim B2 As Variant
Dim B3 As Variant
Dim Var1 As Variant
Dim Var2 As Variant
Dim Var3 As Variant
Dim Var4 As Variant
Dim Var5 As Variant
Dim Var6 As Variant
Set B1 = (Left(Draw, 1))
Set B2 = (Left(Right(Draw, 2), 1))
Set B3 = (Right(Draw, 3))
Set Var1 = Trim([B1] & [B2] & [B3])
Set Var2 = Trim([B1] & [B3] & [B2])
Set Var3 = Trim([B2] & [B1] & [B3])
Set Var4 = Trim([B2] & [B3] & [B1])
Set Var5 = Trim([B3] & [B2] & [B1])
Set Var6 = Trim([B3] & [B1] & [B2])
Select Case [Digi]
Case [Var1], [Var2], [Var3], [Var4], [Var5], [Var6]
[GetHit] = "HIT"
Case Else
[GetHit] = ""
End Select
End Function
Althought I try to use TRIM to make the results clearly text it won't work. I originally compiled all my variables to text but then the code would not compile so I made them all variant type.
Any help would be appreciated.