|
-
May 15th, 2010, 09:37 PM
#1
Thread Starter
New Member
[RESOLVED] Project Help
Hello, I am doing a project for school and I really need help. The object of the project is to get the time and when i press a radio button for the time to get converted into text and vice versa. My problem is that when I convert the time into text, it will not stay because it converts back into numbers. Apparently I am supposed to use a boolean to keep it at text. Can anyone help? My code is below:
Public Class Form1
Dim strFullTime As String
Dim strHours As String
Dim strMinutes As String
Dim strSeconds As String
Dim strAMPM As String
Dim intMinutes As Integer
Dim intSeconds As Integer
Dim intHours As Integer
Dim blnShow As Boolean
Dim strAll As String
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
lblClock.Text = Now().ToString("T")
strFullTime = Now().ToString("T")
If strFullTime.Length = 10 Then
strHours = strFullTime.Substring(0, 1)
strMinutes = strFullTime.Substring(2, 2)
strSeconds = strFullTime.Substring(5, 2)
strAMPM = strFullTime.Substring(8, 2)
intHours = CInt(strHours)
intMinutes = CInt(strMinutes)
intSeconds = CInt(strSeconds)
strAll = ConvertTwoDigits(intHours) & " " & ConvertTwoDigits(intMinutes) & " " & strAMPM & " " & "and " & ConvertTwoDigits(intSeconds) & " Seconds"
Else
lblClock.Text = strMinutes
strHours = strFullTime.Substring(0, 2)
strMinutes = strFullTime.Substring(3, 2)
strSeconds = strFullTime.Substring(6, 2)
strAMPM = strFullTime.Substring(9, 2)
strAll = ConvertTwoDigits(intHours) & " " & ConvertTwoDigits(intMinutes) & " " & strAMPM & " " & "and " & ConvertTwoDigits(intSeconds) & " Seconds"
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
Function ConvertTwoDigits(ByVal strDigits As String) As String
If strDigits.Length = 1 Then
Return ConvertDigit(strDigits)
End If
Select Case strDigits
Case "10"
Return "Ten"
Case "11"
Return "Eleven"
Case "12"
Return "Twelve"
Case "13"
Return "Thirteen"
Case "14"
Return "Fourteen"
Case "15"
Return "Fifteen"
Case "16"
Return "Sixteen"
Case "17"
Return "Seventeen"
Case "18"
Return "Eighteen"
Case "19"
Return "Nineteen"
Case "20" To "29"
Return "Twenty " & ConvertDigit(strDigits.Substring(1))
Case "30" To "39"
Return "Thirty " & ConvertDigit(strDigits.Substring(1))
Case "40" To "49"
Return "Forty " & ConvertDigit(strDigits.Substring(1))
Case "50" To "59"
Return "Fifty " & ConvertDigit(strDigits.Substring(1))
Case Else
Return "Error"
End Select
End Function
Function ConvertDigit(ByVal strDigit As String) As String
Select Case strDigit
Case "0"
Return ""
Case "1"
Return "One"
Case "2"
Return "Two"
Case "3"
Return "Three"
Case "4"
Return "Four"
Case "5"
Return "Five"
Case "6"
Return "Six"
Case "7"
Return "Seven"
Case "8"
Return "Eight"
Case "9"
Return "Nine"
Case Else
Return " "
End Select
End Function
Private Sub btnSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSet.Click
If radText.Checked Then
ElseIf radNumeric.Checked Then
End If
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|