|
-
Nov 25th, 2005, 11:18 AM
#1
Thread Starter
New Member
what is # in vb?
Hi All,
I've to fix an old vb6 code and I've encounter the following lines
hours = 300#
if test * 100#/hours = abc then
' do something
end if
what is this # doing in the above code? I've never seen it before. I am completely stuck and can't move forward in my work until i figure out what this # is.
thank you very much
-
Nov 25th, 2005, 11:34 AM
#2
Re: what is # in vb?
I think it forces the number into double (if not its single or currency)
-
Nov 25th, 2005, 11:34 AM
#3
Re: what is # in vb?
Moved from CodeBank
Hi khaleefa, welcome to VBForums! 
The # is a shortcut for the data type Double, so this:
is the same as:
In your example it is just ensuring that the numbers 100 and 300 are worked with as Double rather than integer (I'm not sure why tho!).
-
Nov 25th, 2005, 11:38 AM
#4
Thread Starter
New Member
Re: what is # in vb?
great, thank you veryyy much for your help (both of you
-
Nov 25th, 2005, 12:28 PM
#5
Member
Re: what is # in vb?
Just like to add for Khaleefa's benefit,
! = Single
& = Long
@ =Currency
-
Nov 25th, 2005, 12:29 PM
#6
Thread Starter
New Member
Re: what is # in vb?
oh GOD, why couldn't they do it a simpler and more logical way?
anyways thank you W00dy
-
Nov 25th, 2005, 01:46 PM
#7
Re: what is # in vb?
% = Integer
$ = String
 Originally Posted by si_the_geek
In your example it is just ensuring that the numbers 100 and 300 are worked with as Double rather than integer (I'm not sure why tho!).
Well VB treats numbers without a decimal as Integers unless they are to large in which case a Long is automatically used. By adding the # sign after those integer numbers VB will treat it as a Double already at compile time which makes the code run slightly faster since VB doesn't need to convert the Integer into a Double at run-time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|