Access VBADiscuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Although you think that vbTab is a string character consisting of a tab, it is not. The intrinstic constant vbTab is a number (I forget if it's a byte or integer) and is used in leiu of CHR(9) for easy concatenation of strings for programers. Try using CHR(9) instead of vbTab and see if you still get a type mismatch error. If so, then tabs are not treated as string characters by the SPLIT function.
Michigan Dept. of Environmental Quality, Air Quality Division
The type mismatches come at different places in each of the 3 code snippets you posted, that's why you're getting confused.
For starters, Split returns an array so your 1st one "Dim t As String" is no good.
Your 2nd one, dim v as variant, is fine. A Variant can contain an array so that's OK. Your Type Mismatch in this case comes from the line "MsgBox v". MsgBox can't work on an array - had you put "MsgBox v(0)" it would have been fine.
Your 3rd one "dim arr(2) as string" is no good because you have sized the array in advance. Had you used "dim arr() as string" instead then this one would be fine too.