First I am going to test to see if the general principles work.
Const month_list As String = "january february march april may june july august september october november december"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim monthName As String
monthName = InputBox("Enter a month")
monthName = monthName.ToLower
If month_list.Contains(monthName) = True Then
MessageBox.Show("That is a month")
Else
MessageBox.Show("That is not a month")
End If
End Sub
OK here is the finished product. Debating whether or not to do a quick tutorial. Will smoke a cigarrette and walk to QT while deciding.
Public Class Form1
Const month_list As String = "january february march april may june july august september october november december"
Const month_31 As String = "january march may july august october december"
Const January_value As Integer = 31
Const February_value As Integer = 28
Const March_value As Integer = 31
Const April_value As Integer = 30
Const May_value As Integer = 31
Const June_value As Integer = 30
Const July_value As Integer = 30
Const August_value As Integer = 31
Const September_value As Integer = 30
Const October_value As Integer = 31
Const November_value As Integer = 30
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim monthString, doAnother As String
Dim dayInteger, totalValue, totalRemainingValue As Integer
Dim i As Integer = 1
Dim yesOrNo As String
Dim totalRemaingValue As Integer = 0
Do
totalRemaingValue = 0
dayInteger = 0
totalValue = 0
monthString = ""
dayInteger = 0
getMonth(monthString)
getDay(monthString, dayInteger)
getMonthValue(monthString, dayInteger, totalValue)
totalRemaingValue = subtractTotalValue(totalValue)
txtInfo.Text = txtInfo.Text & "Entry " & i & vbTab & monthString.ToUpper & " " & dayInteger & vbTab & totalRemaingValue & " days left in the year." & vbCrLf
i += 1
yesOrNo = InputBox("Do you want to enter another date? Enter NO to stop")
yesOrNo = yesOrNo.ToLower
Loop While yesOrNo <> "no"
End Sub
Sub getMonth(ByRef monthString)
Dim monthCorrect As Boolean = False
While monthCorrect = False
While isNull(monthString) = True
monthString = InputBox("Please enter a month")
End While
monthString = monthString.ToLower
If month_list.Contains(monthString) = True Then
MessageBox.Show("You entered the month " & monthString)
monthCorrect = True
Else
MessageBox.Show("You entered " & monthString & " which is incorrect. Please try again.")
End If
End While
End Sub
Sub getDay(ByVal monthString, ByRef dayInteger)
While dayInteger = 0
dayInteger = InputBox("Please enter a date for the day.")
If dayInteger = "" Then
MessageBox.Show("Please enter a number.")
dayInteger = 0
Else
If monthString.tolower = "february" Then
If dayInteger >= 1 And dayInteger <= 28 Then
MessageBox.Show("You have entered " & monthString.ToUpper & " " & dayInteger)
Else
MessageBox.Show("You entered " & dayInteger & ". That is incorrect. Please try again.")
dayInteger = 0
End If
ElseIf month_31.Contains(monthString) Then
If dayInteger >= 1 And dayInteger <= 31 Then
MessageBox.Show("You have entered " & monthString.ToUpper & " " & dayInteger)
Else
MessageBox.Show("You entered " & dayInteger & ". That is incorrect. Please try again.")
dayInteger = 0
End If
Else
If dayInteger >= 1 And dayInteger <= 30 Then
MessageBox.Show("You have entered " & monthString.ToUpper & " " & dayInteger)
Else
MessageBox.Show("You entered " & dayInteger & ". That is incorrect. Please try again.")
dayInteger = 0
End If
End If
End If
End While
End Sub
Sub getMonthValue(ByVal monthString, ByVal dayInteger, ByRef totalValue)
Select Case monthString.tolower
Case "january"
totalValue = dayInteger
Case "february"
totalValue = dayInteger + January_value
Case "march"
totalValue = dayInteger + January_value + February_value
Case "april"
totalValue = dayInteger + January_value + February_value + March_value
Case "may"
totalValue = dayInteger + January_value + February_value + March_value + April_value
Case "june"
totalValue = dayInteger + January_value + February_value + March_value + April_value + May_value
Case "july"
totalValue = dayInteger + January_value + February_value + March_value + April_value + May_value + June_value
Case "august"
totalValue = dayInteger + January_value + February_value + March_value + April_value + May_value + June_value + July_value
Case "september"
totalValue = dayInteger + January_value + February_value + March_value + April_value + May_value + June_value + July_value + August_value
Case "october"
totalValue = dayInteger + January_value + February_value + March_value + April_value + May_value + June_value + July_value + August_value + September_value
Case "november"
totalValue = dayInteger + January_value + February_value + March_value + April_value + May_value + June_value + July_value + August_value + September_value + October_value
Case "december"
totalValue = dayInteger + January_value + February_value + March_value + April_value + May_value + June_value + July_value + August_value + September_value + October_value + November_value
End Select
End Sub
Function isNull(ByVal variableHolder)
If variableHolder = "" Then
Return True
Else
Return False
End If
End Function
Function subtractTotalValue(ByVal totalValue)
totalValue = 365 - totalValue
Return totalValue
End Function
End Class
Here I am trying to work with rectangular arrays
Dim numbersArray(7, 2) As Integer
Dim numbersString As String = ""
Dim arrayFillerOne As Integer = 0
Dim arrayFillerTwo As UInteger = 0
For integerCounter As Integer = 1 To numbersArray.GetLength(0) - 1
arrayFillerONe = integerCounter * 3
arrayFillerTwo = integerCounter * 4
numbersArray(integerCounter, 0) = arrayFillerOne
Next
For i As Integer = 0 To numbersArray.GetLength(0) - 1
For j As Integer = 0 To numbersArray.GetLength(1) - 1
numbersString &= numbersArray(i, j) & vbTab
TextBox1.Text = numbersString
Next
numbersString &= vbCrLf
Next
I think I've gotten the hang of it. It is a bit tricky to convert numbers into spaces, and vice versa.
Dim numbersArray(7, 2) As Integer
Dim numbersString As String = ""
Dim arrayFillerOne As Integer = 0
Dim arrayFillerTwo As UInteger = 0
For i = 0 To numbersArray.GetLength(0) - 1
numbersArray(i, 0) = i * 3
numbersArray(i, 1) = numbersArray(i, 0) + 5
numbersArray(i, 2) = numbersArray(i, 1) + numbersArray(i, 0)
Next i
For i As Integer = 0 To numbersArray.GetLength(0) - 1
For j As Integer = 0 To numbersArray.GetLength(1) - 1
numbersString &= numbersArray(i, j) & vbTab
TextBox1.Text = numbersString
Next
numbersString &= vbCrLf
Next
No comments:
Post a Comment