Results 1 to 5 of 5

Thread: How to use the Arrays in Visual Basic?

  1. #1
    Join Date
    Aug 2006
    Posts
    201

    How to use the Arrays in Visual Basic?

    I want to make a game of Poker in VB. But for making that game I will have to use the concept of array and I don't know much about arrays. So can anyone provide the useful information (or coding) about using an Arrays in Visual Basic?? Also if possible tell me the different types of the arrays that are used in the different types of scenario.!! Please provide the useful suggestions as soon as possible.!
    Don't be afraid of darkness, it's in your heart anyway.

  2. #2
    Join Date
    Nov 2008
    Posts
    996

    Re: How to use the Arrays in Visual Basic?

    Since you don't know much about an array, you should first clear the concepts of that before moving to the actual programming of that. You can refer to multiple values by the same name, using a number called an index or subscript to distinguish them from one another, when you are using an Arrays. You code can be simplified as well as can be shortened by using an array. Array allows you to create loops that deal efficiently with any number of elements. An array can be defined as a set of values that are logically related to each other. An array allows you to refer to these related values by the same name and to use a number, called an index or subscript. The individual values are called the elements of the array.

  3. #3
    Join Date
    Nov 2008
    Posts
    1,192

    Re: How to use the Arrays in Visual Basic?

    There are various array dimensions in Visual Basic. A direction in which you can vary the specification of an array's elements is known as a dimension. Consider the following examples for different types of the arrays :
    1. An array that holds the sales total for each day of the month has one dimension (the day of the month).
    2. An array that holds the sales total by department for each day of the month has two dimensions (the department number and the day of the month).
    The number of dimensions an array has is called its rank. By supplying an index or subscript for each of its dimensions, you can specify an element of an array.
    Types of the Dimensions :
    One Dimension - Many arrays have only one dimension, such as the number of people of each age.The following example declares a variable to hold a one-dimensional array of age counts for ages 0 through 100.
    Code:
    Dim ageCounts(100) As UInteger
    Two Dimensions - Some arrays have two dimensions, such as the number of offices on each floor of each building on a campus. The following example declares a variable to hold a two-dimensional array of office counts, for buildings 0 through 25 and floors 0 through 10.
    Code:
    Dim officeCounts(25, 10) As Byte
    Three Dimensions - A few arrays have three dimensions, such as values in three-dimensional space. The following example declares a variable to hold a three-dimensional array of air temperatures at various points in a three-dimensional volume.
    Code:
    Dim airTemperatures(55, 75, 35) As Single
    More than Three Dimensions - Although an array can have as many as 32 dimensions, it is rare to have more than three.
    Last edited by void; 21-01-2010 at 08:15 PM.

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to use the Arrays in Visual Basic?

    Using the Dim statement, you can declare an array variable. If you want to declare a one-dimensional array variable, then you will have to add one pair of parentheses after the variable name. And if you want to declare a multidimensional array variable, then you will have to add one pair of parentheses after the variable name and place commas inside the parentheses to separate the dimensions. If you want to declare a jagged array variable, you will have to add as many pairs of parentheses after the variable name as there are levels of nested arrays.

  5. #5
    Join Date
    May 2008
    Posts
    2,389

    Re: How to use the Arrays in Visual Basic?

    If you want to create an array in the array declaration statement, then you will have to add a a New clause after the variable name and its parentheses. I have provided you the code of the Arrays in Visual Basic :
    Code:
    Dim CustName(10) As String 
    Dim num As Integer 
    Private Sub addName() 
        For num = 1 To 10 
            CustName(num) = InputBox("Enter the Customer name", "Enter Name", "", 1500, 4500) 
            If CustName(num) <> "" Then 
                Form1.Print CustName(num) 
            Else 
                End 
            End If 
        Next 
    End Sub 
      
    Private Sub Exit_Click() //exit command button
        End 
    End Sub 
    
    Private Sub Start_Click() //start command button
        Form1.Cls 
        addName

Similar Threads

  1. Arrays in Visual Basic 6.0
    By Palnila in forum Software Development
    Replies: 3
    Last Post: 26-12-2010, 09:17 AM
  2. Sample of Visual Basic macros for working with arrays in Excel
    By Silent~Kid in forum Windows Software
    Replies: 5
    Last Post: 12-03-2010, 03:43 AM
  3. what are Visual Basic IDE?
    By Naresh Modi in forum Software Development
    Replies: 2
    Last Post: 06-03-2009, 09:49 AM
  4. Is GUI same like Visual Basic ?
    By Caesar in forum Software Development
    Replies: 2
    Last Post: 02-03-2009, 01:32 PM
  5. Visual Basic 2005 or Visual Basic 6
    By Aasha in forum Software Development
    Replies: 5
    Last Post: 15-01-2009, 06:56 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,213,736.95537 seconds with 17 queries