What is the VB.NET Equiv. of Functions like Fix, ASC and in which library can they be found ?
Printable View
What is the VB.NET Equiv. of Functions like Fix, ASC and in which library can they be found ?
VB Code:
'asc Dim asciiValue As Integer = System.Text.Encoding.ASCII.GetBytes(c)(0)
the namespace is microsoft.visualbasic
As far as Fix.... the framework will truncate if you cast a single of (3.5) into an integer, the .5 will drop off.
VB Code:
example: Dim total As Integer = CType(3.2!, Integer)
I think that ends up being more of a crutch than helpfull.. if one is going to make the leap to VB.NET, just do it.... don't stick one foot on one side and one on the other.... commit or not.Quote:
Originally posted by Andy
the namespace is microsoft.visualbasic
TG
i agree.. i was looking for the left function and i was like "where the hell is it" looked it up in help and it said you HAVE to fully qualify it in a form because of the forms left property (this happened in VB6 with intellisense too)
then i realized that this functionality is built right into string objects like the substring method
i agree. I was just quoting what I found in the MSDN. :D Can you use those functions without importing that namespace? What ARE the equivalent .net methods?
Do you know that there are some mathematical functions in the Math class ?
VB Code:
'Fix Math.Ceiling '(If you pass 3.5 it will give 4) Math.Floor ' (If you pass 3.5 it will give 3) 'both only return whole numbers
As far as I could ever tell, Fix simply truncates the decimal fraction of a number.... I guess its easier than typing out the conversion, perhaps not in c# though... result = (int)mySingle.
is THAT what the Math class does? :DQuote:
Originally posted by Pirate
Do you know that there are some mathematical functions in the Math class ?
Ofcourse , I don't know mean that basic mathematical functions (+ - / *)....:confused:Quote:
Originally posted by Andy
is THAT what the Math class does? :D
spoiledkid i hate to say this, and I am not being sarcastic at all, but in the MSDN help with .NET, if you look up those functions by name you will get the documentation on them
I have seen the documentation on those, they are part of Microsoft.VisualBasic namespace which gives me a feeling that this namespace is just for backward compatibility ... I do not want to use anything of VB6 so I asked if there was a equivalent in .net
yeah I have yet to find something in the Microsoft.VisualBasic namespace that there is not a .net function that does the same thing
:confused:Quote:
Originally posted by kleinma
yeah I have yet to find something in the Microsoft.VisualBasic namespace that there is not a .net function that does the same thing
I like my car...
then go to chit-chatQuote:
Originally posted by nemaroller
I like my car...
The only VB6 -> .NET thing I am struggling with is the Format function. I have still not figured that one out.
For example, If I have a value x = 9, how do I format that to be 9.00? I have been using the microsoft.visualbasic namespace but would rather just use the framework to do the formatting.
VB.NET uses strings to format numbersQuote:
Originally posted by VBGuy
The only VB6 -> .NET thing I am struggling with is the Format function. I have still not figured that one out.
For example, If I have a value x = 9, how do I format that to be 9.00? I have been using the microsoft.visualbasic namespace but would rather just use the framework to do the formatting.
VB Code:
Dim mystring As String Dim mynumber As Double = 9 mystring = FormatNumber(mynumber, 2)
gives the string 9.00
I have been using the microsoft.visualbasic namespace but would rather just use the framework to do the formatting.
Here you go, just use an overloaded method of the ToString function:
VB Code:
Dim my9 As Single = 9.121 Dim myString As String = my9.ToString("#.00")) 'gives 9.12 Dim myDouble As Double = 1234567890 Dim myString As String = myDouble.ToString( "(###) ### - ####" ) ' gives (123) 456 – 7890 'or use the Format function Dim price As Double = 3.21 Dim myString As String = String.Format("{0:c}", price) ' gives $3.21
http://msdn.microsoft.com/library/de...matstrings.asp
http://msdn.microsoft.com/library/de...matstrings.asp
this post or a gathering of the c#/vb.net commands that are used to convert one another would make a great sticky or FAQ.