Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For x = 1 To 10
For y = 1 To 10
Dim button1 As New Button
button1.Location = New Point(40 * x, 40 * y)
button1.Width = 40
Me.Controls.Add(button1)
button1.Text = x * y
Next
Next
End Sub
Sunday, May 8, 2011
Programmatic adding of elements
This code will create a times table..
Saturday, May 7, 2011
Values and Formulas
In this blog i will show how to problem solve :
1. morgan collecting stuffed animals prooblem
dim score ,math, science,eng, geo as decimal
dim score as double =
dim total as decimal
1. morgan collecting stuffed animals prooblem
- set variables for the animals being counted
- cows(c) sheep(s) and total(t)
- determine a formula for solving the problem
- c + s= t
- Morgan has 6 cows and 7 sheep so
- 6+7= 13
- burgers * price
- 4*7= 28
- dim apples as double = 15
- dim oranges as double = 12
- dim horse as double = 33
- dim apples, oranges as double
- apples= 15
- oranges = apples*3
dim score ,math, science,eng, geo as decimal
dim score as double =
dim total as decimal
- math+ science = 25
- score - total= 7
- total /4 = 14
Conditionals
Problem # 1 : Here i am gonna demonstrate how to make a shipping calculator:
This is an example of a program that will control the heater and AC
Here i am going to demonstrate a clothing size calculator:
Dim shipping As Decimal = 50
Dim price As Decimal
Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
price = shipping + txtPurchasePrice.Text
If price > 50 Then
shipping = 0
End If
MsgBox(("Your Total Price is: " & FormatCurrency(price)))
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtPurchasePrice.Text = ""
End Sub
This is an example of a program that will control the heater and AC
Dim temperature As Double
Dim Heat, AC As Double
Private Sub btnTempControl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTempControl.Click
temperature = txtCalcTemp.Text
If temperature < 72 Then
MsgBox("The Heater is being activated ")
Else
If temperature > 76 Then
MsgBox("The AC is being activated")
Else
MsgBox("the system is idle")
End If
End If
End Sub
Here i am going to demonstrate a clothing size calculator:
Dim age As Double
Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
age = txtAgeInput.Text
If age <= 2 Then
MsgBox("you should go with XS")
Else
If age <= 4 Then
MsgBox("Small")
Else
If age <= 8 Then
MsgBox("Medium is the way to go")
Else
If age <= 12 Then
MsgBox("Large")
Else
If age > 13 Then
MsgBox("XL")
End If
End If
End If
End If
End If
Friday, April 1, 2011
Array Project (days of the week)
Days of the week Project
Dim week As New Hashtable 'declare at class leve
Dim day As DictionaryEntry
week.Add("Sunday", "Day 1")
week.Add(Monday", "Day 2")"
week.Add(Tuesday", "Day 3")"
week.Add(Wednesday", "Day 4")"
week.Add(Thursday", "Day 5")"
week.Add("Friday", "Day 6")"
week.add("Saturday", "day 7")'Display a single Item
MsgBox(day.Key)For Each day In week
Next
txtTitle.Text = ""
Array Project *revised
Here is an example of a Printer Queue:
In this example i am going to demonstrate how to create an array that will store users; Name(first and last), and Email address.
Dim printJobs As New Queue
Private Sub btnSendJob_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendJob.Click
Dim printer As New Hashtable
printer.Add("Title", (txtTitle.Text))
printer.Add("Pages", (cbPages.Text))
printJobs.Enqueue(printer)
lstJobs.Items.Clear()
For Each h As Hashtable In
printJobs
lstJobs.Items.Add(h.Item("Title") & " " & (h.Item("Pages")))
Next
txtTitle.Text = ""
Me.cbPages.Items.Remove("")
End Sub
Private Sub btnClearCurrent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearCurrent.Click
lstJobs.Items.Clear()
End Sub
End Class
In this example i am going to demonstrate how to create an array that will store users; Name(first and last), and Email address.
Dim Names As New Hashtable
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Names(1) = (txtFirstName.Text)
Names(2) = (txtLastName.Text)
Names(3) = (txtEmail.Text)
txtEmail.Clear()
txtFirstName.Clear()
txtLastName.Clear()
End Sub
Private Sub btnFirstName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirstName.Click
MsgBox(Names(1))
End Sub
Private Sub btnLastName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLastName.Click
MsgBox(Names(2))
End Sub
Private Sub btnEmail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEmail.Click
MsgBox(Names(3))
End Sub
End Class
Tuesday, March 8, 2011
In this post I will show how to set different variables types.
This is code show how to set integer, decimal,and string data types:
1: Dim Apples As Integer 2: Dim bible As Decimal 3: Dim corral As String
Sunday, March 6, 2011
int and string arrays , ArrayList, HashTables and Queue
This Code will show how how to create an arraylist, hashtable and a queue
Public Class frmTestArrayHash
Dim queueList As New Queue
Dim weeks As New Hashtable
Dim sport As ArrayList
Private Sub btnHashTable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHashTable.Click
Dim weeks As New Hashtable
Dim day As DictionaryEntry
weeks.Add("1", "Sun")
weeks.Add("2", "Mon")
weeks.Add("3", "Tue")
weeks.Add("4", "Wed")
weeks.Add("5", "Thu")
weeks.Add("6", "Fri")
weeks.Add("7", "Sat")
'Display a single Item
MsgBox(weeks.Item("5"))
'Search an Item
If weeks.ContainsValue("Tue") Then
MsgBox("Find")
Else
MsgBox("Not find")
End If
'remove an Item
weeks.Remove("3")
'Display all key value pairs
For Each day In weeks
MsgBox(day.Value)
Next
End Sub
Private Sub btnArrayList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnArrayList.Click
Dim sport(5) As String
Dim i As Integer
sport(0) = "Soccer"
sport(1) = "Cricket"
sport(2) = "Rugby"
sport(3) = "Aussie Rules"
sport(4) = "BasketBall"
sport(5) = "Hockey"
For i = 0 To sport.Length - 1
MessageBox.Show("The sport you chose is " & sport(i))
Next
'displaying value from array
End Sub
Private Sub btnQueue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQueue.Click
Dim vince As String
queueList.Enqueue("Sun")
queueList.Enqueue("Mon")
queueList.Enqueue("Tue")
queueList.Enqueue("Wed")
queueList.Enqueue("Thu")
queueList.Enqueue("fri")
queueList.Enqueue("Sat")
Do While queueList.Count > 0
vince = queueList.Dequeue
MsgBox(vince)
Loop
End Sub
End Class
Subscribe to:
Posts (Atom)