vb.net

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
vb.net [2018/02/23 09:50] – created lenshandvb.net [2020/09/18 13:20] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== VB.NET ====== ====== VB.NET ======
  
- *  Arrays and Select Case +[[Arrays and Select Case|Arrays and Select Case]]
-<code> +
-Dim strVehicleModel As String +
-    Dim LowPrice, highPrice As Decimal +
-    Private Sub drpVehicle_SelectedIndexChanged(sender As Object, e As EventArgs) Handles drpVehicle.SelectedIndexChanged +
-        Dim vehicle As String +
-        vehicle = drpVehicle.SelectedItem+
  
 +Arrays allow you to store a range of items of the same datatype. an array is a variable with a single name that represents many different items. When we work with a single item, we only need to use one variable. However, if we have a list of items which are of similar type to deal with, we need to declare an array of variables for each item.
  
-        'Declare the carMake array +An array can be one-dimensional or multidimensional. A one-dimensional array is like a list of items or a table that consists of one row of items or one column of items.
-        Dim strMake(12) As String +
-        strMake(0) = "Alfa Romeo" +
-        strMake(1) = "Aston Martin" +
-        strMake(2) = "Bentley" +
-        strMake(3) = "BMW" +
-        strMake(4) = "Citroen" +
-        strMake(5) = "Dacia" +
-        strMake(6) = "Fiat" +
-        strMake(7) = "Ford" +
-        strMake(8) = "Land Rover" +
-        strMake(9) = "Mercedes Benz" +
-        strMake(10) = "Suzuki" +
-        strMake(11) = "Tesla" +
-        strMake(12) = "Volkswagen"+
  
-        'Declare the Rooms array +^Names^ 
-        Dim strTruck(5) As String +|Peter|Paul|James|Suzie| 
-        strTruck(0) = "Isuzu" +|index(0)|index(1)|index(2)|index(3)|
-        strTruck(1) = "Iveco" +
-        strTruck(2) = "Mann" +
-        strTruck(3) = "Mercedes Benz Truck" +
-        strTruck(4) = "Scania" +
-        strTruck(5) = "Volvo"+
  
-        'Add the array to the comboBox +Declaring one dimensional Array
-        Select Case vehicle +
-            Case "Cars" +
-                drpModel.DataSource = strMake +
-            Case "Trucks" +
-                drpModel.DataSource = strTruck +
-            Case Else +
-        End Select +
-    End Sub+
  
-    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load +The general syntax to declare a one dimensional array is as follows:
-        'Declare the Rooms array +
-        Dim strVehicleChoice(1) As String +
-        strVehicleChoice(0) = "Cars" +
-        strVehicleChoice(1) = "Trucks"+
  
-        'Add the array to the comboBox +<code> 
-        drpVehicle.DataSource = strVehicleChoice +Dim arrayName(subscriptas dataType  
-    End Sub +</code>
- +
-    Private Sub drpModel_SelectedIndexChanged(sender As Object, e As EventArgsHandles drpModel.SelectedIndexChanged +
-        'Get the room or event and set the price and the image if available+
  
-        strVehicleModel drpModel.SelectedItem+==== Week commencing 23 April 2018 ====
  
 +{{ :digapp:sdt-week2.pptx |Week 2 notes}}
  
-        Select Case strVehicleModel +{{ :tennis_court.pdf |Tennis courts}}
-            Case "Alfa Romeo" +
-                LowPrice = 11995 +
-                highPrice = 79999+
  
-            Case "Aston Martin" 
-                LowPrice = 98500 
-                highPrice = 279999 
  
-            Case "Bentley" 
-                LowPrice = 169995 
-                highPrice = 229999 
-            Case "Volvo" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case "BMW" 
-                LowPrice = 11995 
-                highPrice = 279999 
-            Case "Citroen" 
-                LowPrice = 8995 
-                highPrice = 29999 
-            Case "Dacia" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case "Fiat" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case "Ford" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case "Land Rover" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case "Mercedes Benz" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case "Suzuki" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case "Tesla" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case "Volkswagen" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case "Isuzu" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case "Iveco" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case "Mann" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case "Mercedes Benz Truck" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case "Scania" 
-                LowPrice = 11995 
-                highPrice = 79999 
-            Case Else 
-        End Select 
-        Label4.Text = "Low price is " + FormatCurrency(LowPrice.ToString) 
-        Label5.Text = "High price is " + FormatCurrency(highPrice.ToString) 
-    End Sub 
-</code 
  • vb.net.1519379456.txt.gz
  • Last modified: 2020/09/18 13:18
  • (external edit)