0% found this document useful (0 votes)
62 views4 pages

Smart Device Project 1

The document contains code for two forms in a Visual Basic application. Form1 contains code to populate and manage a combo box of city names. It allows adding, removing, and clearing cities from the list. Form2 contains a date time picker that extracts the year, month, day, day of week, and time from the selected date and displays it in text boxes, translating the numeric day of week value to a word.

Uploaded by

Julio Dimar P. R
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views4 pages

Smart Device Project 1

The document contains code for two forms in a Visual Basic application. Form1 contains code to populate and manage a combo box of city names. It allows adding, removing, and clearing cities from the list. Form2 contains a date time picker that extracts the year, month, day, day of week, and time from the selected date and displays it in text boxes, translating the numeric day of week value to a word.

Uploaded by

Julio Dimar P. R
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Public Class Form1 Sub contar() Dim ciudades As Integer ciudades = ComboBox1.Items.Count Me.Text = ciudades.

ToString() & " cuidades " End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ComboBox1.Items.Add("arequipa") ComboBox1.Items.Add("tacna") End Sub Private Sub btnagregar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnagregar.Click 'primer codigo 'Dim ciudad As String 'ciudad = txtnombre.Text 'ComboBox1.Items.Add(ciudad) 'If (ciudad = "") Then ' MsgBox("agregue un nombre para continuar jejejejjeeje...") 'Else ' ComboBox1.Items.Add(ciudad) 'End If 'segundo codigo 'If (txtnombre.Text = "") Then ' MsgBox("falta ingresar un nombre") 'Else ' Dim ciudad As String

' ciudad = txtnombre.Text ' ComboBox1.Items.Add(ciudad) 'End If 'tercer codigo Dim ciudad As String = txtnombre.Text.Trim If ciudad.Length() > 2 Then ComboBox1.Items.Add(ciudad) Else MsgBox("el nombre de la ciudad debe tener 3 o mas letras") End If txtnombre.Text = "" contar() End Sub Private Sub btnquitar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnquitar.Click 'Dim x As Integer 'x = ComboBox1.SelectedIndex 'ComboBox1.Items.RemoveAt(x) 'contar() Dim x As Integer x = ComboBox1.SelectedIndex If x >= 0 Then ComboBox1.Items.RemoveAt(x) contar() Else MsgBox("seleccione una ciudad", , "error") End If End Sub Private Sub btnlimpiartodo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlimpiartodo.Click ComboBox1.Items.Clear() End Sub End Class

Public Class Form2 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged Dim dia As String txtao.Text = DateTimePicker1.Value.Year txtmes.Text = DateTimePicker1.Value.Month txtdia.Text = DateTimePicker1.Value.Day txtsemana.Text = DateTimePicker1.Value.DayOfWeek dia = DateTimePicker1.Value.TimeOfDay.ToString() If txtsemana.Text = "0" Then txtsemana.Text = "domingo" End If If txtsemana.Text = "1" Then txtsemana.Text = "lunes" End If If txtsemana.Text = "2" Then txtsemana.Text = "martes" End If If txtsemana.Text = "3" Then txtsemana.Text = "miercoles" End If If txtsemana.Text = "4" Then txtsemana.Text = "jueves" End If If txtsemana.Text = "5" Then txtsemana.Text = "viernes" End If If txtsemana.Text = "6" Then txtsemana.Text = "sabado" End If Me.Text = DateTimePicker1.Value.TimeOfDay.ToString() End Sub

End Class

You might also like