vinny45
asked on
convert string into time in VB.net
I have 3 dropdown lists. each preloaded with hour, minute and [PM/AM] respectively.
I have code that concatenates these into a string value like "3:00 AM"
I'm having trouble converting that into a dateTime format. Instead i would get todays date with 1:00 AM. Any ideas?
ERF.EventStartTime = Convert.ToDateTime(ESTHour DropDownLi st.Selecte dValue + ":" + ESTMinsDropDownList.Select edValue + " " + ESTampmDropDownList.Select edValue)
I have code that concatenates these into a string value like "3:00 AM"
I'm having trouble converting that into a dateTime format. Instead i would get todays date with 1:00 AM. Any ideas?
ERF.EventStartTime = Convert.ToDateTime(ESTHour
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
'FORM 1
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.ICon
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TextBox1 As System.Windows.Forms.TextB
Friend WithEvents TextBox2 As System.Windows.Forms.TextB
Friend WithEvents TextBox3 As System.Windows.Forms.TextB
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Butto
<System.Diagnostics.Debugg
Me.TextBox1 = New System.Windows.Forms.TextB
Me.TextBox2 = New System.Windows.Forms.TextB
Me.TextBox3 = New System.Windows.Forms.TextB
Me.Label1 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Butto
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(16, 8)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(64, 20)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "3"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(100, 8)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(72, 20)
Me.TextBox2.TabIndex = 1
Me.TextBox2.Text = "0"
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(180, 8)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.TabIndex = 2
Me.TextBox3.Text = "am"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(68, 72)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(164, 23)
Me.Label1.TabIndex = 3
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(192, 120)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 4
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 177)
Me.Controls.Add(Me.Button1
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox
Me.Controls.Add(Me.TextBox
Me.Controls.Add(Me.TextBox
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = CDate(Now.ToShortDateStrin
End Sub
End Class