Solved

variant into string

Posted on 2006-06-16
5
616 Views
Last Modified: 2010-04-30
Hello Guys,
                  I got a string value "A" in a variant array that shows Variant/String type for the string's values. However,
the functions recieving the array's values compalin of type mismatch. How do convert variant into string???

Thanks,
Serge
0
Comment
Question by:Autofreak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 95

Accepted Solution

by:
Lee W, MVP earned 65 total points
ID: 16924405
CStr(Variant)
0
 
LVL 15

Assisted Solution

by:JackOfPH
JackOfPH earned 20 total points
ID: 16925672
dim x
dim y as string

y = cstr(x)
0
 
LVL 20

Assisted Solution

by:alainbryden
alainbryden earned 20 total points
ID: 16925864
you should probably check just to be sure:

Dim x as integer
Dim StrResult As String
Dim VarArray() As Variant
...
...
If isAlphaNumeric( VarArray(x) ) then
   StrResult = CStr( VarArray(x) )
Else
   StrResult = vbNullString
End If
0
 
LVL 8

Assisted Solution

by:kaliyugkaarjun
kaliyugkaarjun earned 20 total points
ID: 16933332
I think u need to loop through the variant and for each item in a variant (i.e. variant_array_name(0), variant_array_name(1),.....) use function cstr() to convert it to string...

0
 

Author Comment

by:Autofreak
ID: 16964476
Thank you Guys, all answeres halped me.
Serge
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Run code from text file in vb 1 86
Macro Excel - Multiple If conditions 2 87
RUNRMTCMD from AS/400 12 86
Access2016 ignore hyphen in data entry or searches 5 43
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question