Hello,
I am new to VisualBasic and trying to learn it online. For my first assignment I have to make a program that allows someone to input a time in AM/PM and select the time zone and automatically output a picture and three other time zones. I think I have it for the most part but I am having an issue with one part in particular. Since the time is input using AM or PM if the original time is 11:00 AM and I add an hour it should switch to PM. But I'm not quite sure what I'm doing wrong. I basically need to say If the time is equal to 12 and the meridiem is equal to am then it should switch to pm but I keep getting errors inidicating they are trying to switch to a boolean value. I have included the code below if anyone can please help me out it would be very much appreciated:
*******************************************
Public Class Form1
Dim time As String
Dim hour As Integer
Dim minutes As String
Dim curTime As String
Dim est As Integer
Dim cst As Integer
Dim mst As Integer
Dim pst As Integer
Dim meridiem As String
Dim ante As String = "AM"
Dim post As String = "PM"
Private Sub fromPacific()
mst = hour + 1
cst = hour + 2
est = hour + 3
If mst = 12 + meridiem = ante Then
ElseIf mst = 12 + meridiem = post Then
meridiem = ante
meridiem = post
End If
If mst > 12 Then mst -= 12
If cst > 12 Then cst -= 12
If est > 12 Then est -= 12
Label1.Text = "MST: " & mst & minutes & meridiem
Label2.Text = "CST: " & cst & minutes & meridiem
Label3.Text = "EST: " & est & minutes & meridiem
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
time = TextBox1.Text
hour = Microsoft.VisualBasic.Left(time, 2)
minutes = Microsoft.VisualBasic.Right(time, 3)
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
PictureBox1.Image = Image.FromFile("C:\Users\Home\Desktop\EST.jpg")
End Sub
Public Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
PictureBox1.Image = Image.FromFile("C:\Users\Home\Desktop\CST.jpg")
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
PictureBox1.Image = Image.FromFile("C:\Users\Home\Desktop\MST.jpg")
End Sub
Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
fromPacific()
PictureBox1.Image = Image.FromFile("C:\Users\Home\Desktop\PST.jpg")
End Sub
Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
If RadioButton5.Checked Then meridiem = ante
End Sub
Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
If RadioButton6.Checked Then meridiem = post
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End
End Sub
End Class
*******************************************
I only posted one of the function fromPacific() for brevity purposes but the other three functions will be similar.
Thanks!
I am new to VisualBasic and trying to learn it online. For my first assignment I have to make a program that allows someone to input a time in AM/PM and select the time zone and automatically output a picture and three other time zones. I think I have it for the most part but I am having an issue with one part in particular. Since the time is input using AM or PM if the original time is 11:00 AM and I add an hour it should switch to PM. But I'm not quite sure what I'm doing wrong. I basically need to say If the time is equal to 12 and the meridiem is equal to am then it should switch to pm but I keep getting errors inidicating they are trying to switch to a boolean value. I have included the code below if anyone can please help me out it would be very much appreciated:
*******************************************
Public Class Form1
Dim time As String
Dim hour As Integer
Dim minutes As String
Dim curTime As String
Dim est As Integer
Dim cst As Integer
Dim mst As Integer
Dim pst As Integer
Dim meridiem As String
Dim ante As String = "AM"
Dim post As String = "PM"
Private Sub fromPacific()
mst = hour + 1
cst = hour + 2
est = hour + 3
If mst = 12 + meridiem = ante Then
ElseIf mst = 12 + meridiem = post Then
meridiem = ante
meridiem = post
End If
If mst > 12 Then mst -= 12
If cst > 12 Then cst -= 12
If est > 12 Then est -= 12
Label1.Text = "MST: " & mst & minutes & meridiem
Label2.Text = "CST: " & cst & minutes & meridiem
Label3.Text = "EST: " & est & minutes & meridiem
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
time = TextBox1.Text
hour = Microsoft.VisualBasic.Left(time, 2)
minutes = Microsoft.VisualBasic.Right(time, 3)
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
PictureBox1.Image = Image.FromFile("C:\Users\Home\Desktop\EST.jpg")
End Sub
Public Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
PictureBox1.Image = Image.FromFile("C:\Users\Home\Desktop\CST.jpg")
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
PictureBox1.Image = Image.FromFile("C:\Users\Home\Desktop\MST.jpg")
End Sub
Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
fromPacific()
PictureBox1.Image = Image.FromFile("C:\Users\Home\Desktop\PST.jpg")
End Sub
Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
If RadioButton5.Checked Then meridiem = ante
End Sub
Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
If RadioButton6.Checked Then meridiem = post
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End
End Sub
End Class
*******************************************
I only posted one of the function fromPacific() for brevity purposes but the other three functions will be similar.
Thanks!