JSON conversion class (1) -- filter special characters, Format String, datetime, Boolean, and json special characters
/// <Summary> /// filter special characters /// </summary> private static string String2Json (String s) {StringBuilder sb = new StringBuilder (); for (int I = 0; I <s. length; I ++) {char c = s. toCharArray () [I]; switch (c) {case '\ "': sb. append ("\" "); break; case '\': sb. append ("\\\\"); break; case '/': sb. append ("\/"); break; case '\ B': sb. append ("\ B"); break; case '\ F': sb. append ("\ f"); break; case '\ N': sb. append ("\ n"); break; case '\ R': sb. append ("\ r"); break; case '\ t': sb. append ("\ t"); break; default: sb. append (c); break;} return sb. toString ();}
/// <Summary> /// Format string, datetime, Boolean // </summary> private static string StringFormat (string str, Type type) {if (type = typeof (string) {str = String2Json (str); str = "\" "+ str + "\"";} else if (type = typeof (DateTime) {str = "\" "+ str +" \ "";} else if (type = typeof (bool )) {str = str. toLower ();} else if (type! = Typeof (string) & string. IsNullOrEmpty (str) {str = "\" "+ str +" \ "" ;}return str ;}
In VB, what are the meanings of type 1 numeric type 2 numeric type 3 Boolean Type 4 date type 5 object type 6 variant?
We recommend that you buy a book. For example: vb.net from entry to entry
Search on Baidu, electronic version, some
Use VB to display various types of data, such as numeric, numeric, date, and Boolean.
Dim a As Integer
Dim B As Boolean
Dim c As Date
Dim d As Byte
Dim s As String
A = 10023
B = True
D = 20
S = CStr ()
Label1.Caption = s
S = CStr (B)
Label2.Caption = s
S = CStr (c)
Label3.Caption = s
S = CStr (d)
Label4.Caption = s