Re: What is wrong with this code?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Randy Birch (rgb_removethis_at_mvps.org)
Date: 03/01/04


Date: Sun, 29 Feb 2004 22:30:50 -0500

VB doesn't care and won't complain about sticking an int into a string ...
it's internal data type coercion (often called evil type coercion) will
easily handle this. Going the other way is a different matter.

Private Sub Command1_Click()

   Dim x As Long
   Dim y As String

   x = 12345
   y = x
   Print x, y
   Print TypeName(x), TypeName(y)

End Sub

-- 
Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
"Steven Burn" <nobody@PVT_it-mate.co.uk> wrote in message 
news:ul540Ew$DHA.2012@TK2MSFTNGP11.phx.gbl...
: xL = integer
: lname = string
:
: Your basically trying to stick an integer into a string, which VB doesn't
: like.
:
: What exactly is your code trying to achieve?
:
: --
: Regards
:
: Steven Burn
: Ur I.T. Mate Group
: www.it-mate.co.uk
:
: Keeping it FREE!
:
: Disclaimer:
: I know I'm probably wrong, I just like taking part ;o)
:
:
: Jack <replyto@newsgroup> wrote in message
: news:#iVHE#v$DHA.1700@TK2MSFTNGP12.phx.gbl...
: > In module:
: > Public lname As String
: > ===========
: > In the subroutine the following code causes error on some computers:
: > "type mismatch, an unexpected error occured".
: > Dim xL As Integer
: >         xL = Int(Timer)
: >         lname = Format(xL)
: >
: > What can be wrong with that?
: >
: >
:
: 

Quantcast