Here are a few ways:
1) int myInt = Convert.ToInt32(myStr);
2) int myInt = int.Parse(myStr);
3) This is the safest way, and includes exception handling:
int myInt;
bool status = int.TryParse(myStr, out myInt);
Val() function is used in Visual Basic 6.0 to convert a string to a numeric value (such as integer, double etc.) or to extract a numeric value out of a string, as illustrated below.Val function as used to convert a string to a numeric valuefor example, let str be a string,Dim str as stringDim int as integerstr="09090"int=val(str)gives int = 9090also, used to extract the numeric part out of a following string,ie. a=val("98ASR_tyui") would give a=98however,b=val("The89")would give b=0 as there is no numeric value preceding the string.
A variable has a data type such as integer, string, double. A data type tells the variable to only store values that are a particular data type, so you can only store numbers without decimal points in an integer variable, and only characters such as "ABCD" in a string variable.
Trunicate is when you trim a string in visual basic
dim value1 as integer dim value2[3] as integer
Dim intNumber As Integer
In the computer programming language Visual Basic, the data type integer is a whole number which can be used in calclations. It can be positive, negative, or zero. The default type of integer is 32-bit, but with "short" and "long" you can have 16- or 64- bit answers. The short data type works well with small numbers and saves RAM space. If overflow is a problem, long works better because of its larger capacity. To take the integer portion of a decimal, single, or double, use the int() function. int(3.925604) returns 3 as a decimal To convert a data type to integer, use cint() cint(int(3.925604)) returns 3 as an integer
declaration of variable is dim a as integer
For i as integer = 1 to 10 ....... Next i
Rounding in Visual Basic is the method of rounding an integer up, or flooring an integer, which is rounding down. To round up, you use the System.Math.Round function. To round down, or floor, you use the System.Math.Floor function.
string length is a function use to check the lenght of a string i.e number of alphabets in a word or sentence.
strlen will return 0, meaning empty string
The variables is visual basic are the items being declared in order to use within the program, for example if you were writing a program for the SUVAT equations the variables would be difined as follows... Dim is as integer Dim iu as integer Dim iV as integer e.c.t Think of the Dim to mean declare and the "as integer" is the data type. If it was a text value (string) for example a name it would be declared as follows: Dim sname as string where sname is the variable. For an array of values you would do the same but as follows: dim sname(100) as string this would create a space so to speak for 101 (0-100) names which would be inputted as so: sname(0) = Dan sname(1) = Sarah e.c.t hope that helps without being to complicated