Arrays and more in VB.Net
Ok, I have vb.net 2003 including the handbook (comes with the vb.net download). Anyways, I am working on a project that will take text you input into it, then change it to a simple encryption I have made, then takes those strings (or arrays, depending if I can do it this way) and put it into binary. What I need to to know is….
*What all can be done with an array, and an array is like a list right?
*If an array is like a list, can whatever you list be given values
*How can I take text inputed and "chop it up" so I can get the values for each letter?
*How do I get remainders to be known in math?
Any help will be appreciated!
*If an array is like a list, can whatever you list be given values
*How can I take text inputed and "chop it up" so I can get the values for each letter?
*How do I get remainders to be known in math?
-
An array can be indexed by using array(x), where array is the array name and x is the item's location in the array. To assign a value, just use a statement like array(x)=value, where value is the value you want to assign.
-
If I recall right, strings can be accessed like arrays. However, for most of my "string chopping", I use nested Strings.Left and Strings.Right functions. For instance, to get the ASCII value of each character in a string, I would do something like:
Dim x as Integer Dim strText as String
strText = whatever
Dim Ascii(strText.Len) as Integer
For x = 1 to strText.Len Ascii(x) = CInt(Strings.Left(Strings.Right(strText, strText.Len-(x-1)),1)) Next
This may not be perfect, but this is the general idea, and I'm sure there's an easier way to do this… I'm just too lazy to read up on accessing a string like an array, so there's a possible solution.
- Finding a remainder like in math is as simple as using the Mod operator. If I recall right, you need to import System.Math to use it, but Mod will return the remainder from dividing by the number after Mod (e.g., 14 Mod 3 = 2).
Hope that helps some.