answersLogoWhite

0


Best Answer

If you are referring to the searching and sorting of strings, there are 2 main methods that Visual Basic uses most. If you want to search for a phrase in a string, you would probably use the InStr method, which would give you an integer which would indicate the place where the phrase was found. It might look something like this:

Dim InputString as String

Dim StringToFind as String = "Whatever text you want to find"

Dim PositionInteger as Integer

PositionInteger = InStr(InputString, StringToFind)

If you wanted to sort the string, you could do it with the substring method using the split point you found with the previous code. To do that, you would make a variable that would contain the latter half of your string, and use the subtring method to extract it from the whold string. To do that, you must type "Substring" and in parenthasis, give it a starting position, and an ending position. If you want all the characters from the phrase to the end of the sting, you do not need to put in an end point. The starting point for this example will be the position of the start of the search phrase, plus thirty (since you want to start after the end of the phrase, which is thirty characters long). Your code might look like this:

Dim NewString as String

NewString = Substring(PositionInteger + 30)

This would make the variable "NewString" contain all the characters following the search phrase.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

The following code declares a list (or array) of TEN numbers...

Dim List(10) As Short

Now, lets say you wanted to enter 25 as the fifth number in the list...

List(5) = 25

What about a list of strings (text)? Replace Short with String!

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Dim Name(1 to 50) as String

"Name" is the identifier name, "1 to 50" are the boundaries for the array - you have to start with 1. And then you declare the data type, in this case a String.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

An array is a collection of values stored in a single variable.

For example, if you had the following temperatures for a month, each in its own variable:

Day1 = 50

Day2 = 52

Day3 = 55

Day4 = 70

... etc. etc.

You could instead store all of those in an array. An array is a variable with parenthesis after it to indicate the ELEMENT of the array.

So, you could do the same thing with an array:

Temperatures(1) = 50

Temperatures(2) = 52

Temperatures(3) = 55

Temperatures(4) = 70

... etc.

This way, if I wanted to know the temperature for day 3, I would reference it as:

Temperatures(3)

Arrays must first be dimensioned. In other words, the memory space for the array must be allocated. In VB, this can be either static or dynamic. Static is used when you know how many elements there will be; so if I wanted an array for 30 days of temperature storage, I would use:

DIM Temperatures(30)

However, if I didn't know how many elements I was going to have, I could use a dynamic array:

DIM Temperatures()

... however, I need to ReDim my array every time I add things to it.

LBOUND and UBOUND will tell you how many elements an array has been dimensioned for... .so you can use the REDIM in conjunction with the UBOUND to add another array element.

For example, I have an array with 4 dimensions. I need to make it bigger...

DIM iArray()

REDIM iArray(4)

iArray(1) = 1

iArray(2) = 2

iArray(3) = 3

iArray(4) = 4

' Add another array dimension

REDIM PRESERVE iArray(UBOUND(iArray()+1)

.... the PRESERVE is very important; if you just REDIM your array without preserve, then the array is cleared.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Use Array.Sort on your stored array, as follows:

Dim intArray As Integer = {1, 4, 2, 6, 10}

Array.Sort(intArray)

This will sort your array in ascending order.

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

An array is an aggregate of elements of the same type.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you create an array in visual basic?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Program to print all the even numbers of an array in visual basic?

find even number in array


What is the history of Visual Basic 6.0?

Visual Basic was first released in 1992 Visual Basic was first released in 1998. This version included the ability to create web-based applications. Support for this version ended in 2005.


What is visual basic control?

Visual Basic Controls work on Visual Studio for Visual Basic and Applications that made by Visual Basic.


Explain how Multidimensional Arrays are used in a Visual Basic application?

Creating a Visual Basic Multidimensional Array Declaring a multidimensional array requires both the number of rows and columns to be defined when the array is created. As with standard arrays, multidimensional arrays are declared using the Dimkeyword: Dim strBooks(4, 2) As String The above Visual Basic code excerpt creates a two dimensional String array of 5 rows and 2 columns. Assigning Values to Multidimensional Array Values are assigned to array elements by specifying the index into each dimension. For example, in a two dimensional array, 0, 0 will references the element in the first column of the first row of the array. The following code initializes each element of our array: Dim strBooks(4, 1) As String strBooks (0, 0) = "Learning Visual Basic" strBooks (0, 1) = "John Smith" strBooks (1, 0) = "Visual Basic in 1 Week" strBooks (1, 1) = "Bill White" strBooks (2, 0) = "Everything about Visual Basic" strBooks (2, 1) = "Mary Green" strBooks (3, 0) = "Programming Made Easy" strBooks (3, 1) = "Mark Wilson" strBooks (4, 0) = "Visual Basic 101" strBooks (4, 1) = "Alan Woods" The above example creates a two dimensional array of 5 rows (remember that indexing starts at 0 so this array have elements from 0 to 4 inclusive) and two columns. Column 1 is the book title and column 2 the author.Answerer 1 Multidimensional arrays are used as follows:-Dim a(m,n) as integerfor putting valuefor i = 1 to mfor j = 1 to na(i , j) = val(inputbox("Enter the value"))s = s & a(i , j) & " "next js = s & vbcrlfnext i


What is the difference between ordinary basic and visual basic?

QBASIC is not a visual language, although it can be used to create very crude visual programs (much like a BIOS screen in appearence). In contrast, Visual Basic can be used to create Windows-Based programs using the appropriate GUI and as such far more user friendly. Personally, I would use PASCAL and DELPHI - Pascal is similar in functionality to QBASIC (although more advanced), but can be used within Delphi to achieve more visual results.

Related questions

How do you create a program in visual basic?

arrays programms in visual basic


Program to print all the even numbers of an array in visual basic?

find even number in array


What is visual basic generally?

Visual Basic is a computer development program. It's used to create .exe or executable programs.


Why visual basic is referred to as a tool?

Visual Basic is a computer programming language that can be used to create programs, but it is not a program in itself.


What program can create with visual basic 6.0?

You can create anything you set your mind to.


What is visual basic 2008?

Visual Basic create windows form applications. They are things like your Web Browser, e.g. Internet Explorer.


What is mean by the term Element of art?

A basic visual symbol an aitist uses to create visual art


What is the history of Visual Basic 6.0?

Visual Basic was first released in 1992 Visual Basic was first released in 1998. This version included the ability to create web-based applications. Support for this version ended in 2005.


Is visual basics only available in Microsoft Excel?

No, Visual Basic is a program on its own too, used to create programs. VBA is used in Excel and other programs (Visual Basic for Applications).


What are the uses of visual basic?

mostly to create programs and write "BASIC" code. somewhat different from the original version


What is visual basic control?

Visual Basic Controls work on Visual Studio for Visual Basic and Applications that made by Visual Basic.


How do you create a save button to save a dataset into a database in Visual Basic?

i love pie