In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how VB.NET implements data conversion. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
There are many methods of VB.NET data conversion. If you want to skillfully master these practical skills, you need to accumulate experience and master this knowledge through continuous practice. That is, you can use the To method directly after the variable or statement. The following is the syntax:
Variable = variable. To type or variable = (narrative). To type
This is because everything in .NET is an object, a variable is an object, a constant is an object, and a description is an object.
These objects themselves provide methods for VB.NET data transformation for us to use. For example, the following example converts a variable of numeric type to a string type
Dim shtNum As Short
ShtNum=12345
Response.Write ("shtNum"
The value in the variable is: "+
ShtNum.ToString ()
The following table shows the common To type conversion methods:
How to use the conversion pattern
Turn the string ToString ()
Numeric character conversion ToChar ()
String to lowercase ToLower ()
String to uppercase ToUpper ()
Turn to a reduced integer ToInt16 ()
Rotate the integer ToInt32 ()
Turn to a long integer ToInt64 ()
Rotation value ToDecimal ()
Change date ToDateTime ()
Transfer to mono-exact ToSingle ()
Turn to double number ToDouble ()
Turn to Boolean ToBoolean ()
Date to simplified date ToShortDateString ()
Time to reduce time ToShortTimeString ()
VB.NET exception handling breaks through limitations
In-depth discussion of VB.NET access control
Detailed analysis of the implementation method of VB.NET dynamic control array
An overview of the five basic elements of VB.NET drawing
Application Foundation of VB.NET Class
VB.NET 's processing of data is strongly typed, which means that operations can only be performed if the two data types are the same. Suppose we have two variables, the strA string type and the shtB reduced integer type, and specify strA= "100" and shtB=10. If you want to add the value of shtB to the value of strA, executing the shtB=shtB+strA statement directly will result in an error. This is because shtB and strA are not of the same data type. Although the content of strA is 10, it is enclosed in double quotes; all enclosed by double quotation marks are treated as strings. If you want to perform the addition operation, you must convert the strA to a numeric type using the type conversion function CShort () before performing the addition calculation. Therefore, the above formula should be changed to shtB=shtB+CShort (strA), which is the correct answer.
Because VB.NET is a strong type, two different types of data must be converted to the same data type before they can be processed.
Yes, VB.NET no longer supports automatic type conversion for older versions of VB. Many functions for type conversion are provided in VB.NET data transformations:
Function transformation type
Cbool Boolean
Cbyte Byte
Cchar Chart
CDate Date
CDbl Double
CDec Decimal
CInt Integer
CLng Long
CObj Object
CShort Short
CSng Single
CStr String
The functions of these VB.NET data transformations are easy to remember, C means Convert conversion, and then all except Short are abbreviated with the type to be converted.
Thank you for reading! This is the end of the article on "how to achieve data conversion in VB.NET". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.