Está en la página 1de 6

PARA REDONDEAR LOS COCIENTES A 2 DECIMALES pro = Math.

Round(pro, 2) PROVOCA UN SALTO DE LINEA vbCrLf MUESTRA UN CUADRO CON UN MENSAJE MsgBox(Contenido,vbINFORMATION,Titulo) EVENTO KEYPRESS If e.KeyChar = ChrW(13) Then TextBox2.Focus() End If TextBox1.Text = USO DEL COMBOBOX Dim dia As Integer dia = ComboBox1.SelectedIndex Select Case dia Case 0, 1, 2 pne = pbr * 1 Case 3, 4 pne = pbr * 0.12 Case 5, 6 pne = pbr * 0.15 End Select EVENTO GOTFOCUS PARA EL COMBOBOX My.Computer.Keyboard.SendKeys("{F4}") LIMPIA LOS ITEMS DEL COMBOBOX Combobox.Text = USO DEL LISTBOX Dim sel As String sel = ListBox1.Items.Item(ListBox1.SelectedIndex) If sel = "Sumar" Then ope = n1 + n2 ElseIf sel = "Restar" Then ope = n1 - n2 ElseIf sel = "Multiplicar" Then ope = n1 * n2 ElseIf sel = "Dividir" Then ope = n1 / n2 Math.Round(ope, 2) End If USO DE LOS RADIOBUTTONS If RadioButton1.Checked = True Then tot = (220 - eda) / 10 Else tot = (210 - eda) / 10 End If tot = Math.Round(tot, 2) TextBox2.Text = CStr(tot)

LIMPIA LOS ITEMS DE UN RADIOBUTTON RadioButton1.Checked = False RadioButton2.Checked = False METODO FUNCTION Function Calcular(ByVal nu As Long) As Long Dim su As Long i=1 su = 0 Do Until i > nu su += i i += 1 Loop Return su End Function LLAMAR AL METODO FUNCTION Dim sum As Long sum = Calcular(num) MENUSTRIP barra de menu TOOLSTRIP barra de botones STATUSSTRIP en el Form ToolStripStatusLabel2.Text = "| Fecha : " + DateString + " | Hora : " + TimeString EVENTOS PARA TEXTBOX Y BUTTON EVENTO GOTFOCUS TextBox3.ForeColor = Color.SkyBlue TextBox3.BackColor = Color.Green EVENTO LOSTFOCUS TextBox2.ForeColor = Color.Black TextBox2.BackColor = Color.White PARA LLAMAR A LOS UTILITARIOS Process.Start("calc") Process.Start("notepad") Process.Start("mspaint") CREACION DEL MODULE Public Sub limpiar(ByVal f As Form) For Each c As Control In f.Controls If TypeOf c Is TextBox Then c.Text = "" End If Next End Sub LLAMANDO AL MODULE DEL BUTTON Call Module1.limpiar(Me) TextBox1.Focus() ACEPTA SOLO MAYUSCULAS EN EL TEXTBOX TextBox3.CharacterCasing = CharacterCasing.Upper

EJERMPLO DE CURSIVA NEGRITA NORMAL Y COLOR EN EL COMBOBOX EN EL FORM Dim fuentes As FontFamily For Each fuentes In System.Drawing.FontFamily. Families ComboBox1.Items.Add(fuentes.Name) Next TextBox1.Text = "Uso de Fuentes en VisuBasi nom_fue = "Comic Sans MS" tam_fue = ListBox1.Items.Item(1) ComboBox1.Text = "Comic Sans MS" ListBox1.Text = 8 nom_fue = ComboBox1.Text TextBox1.Font = New System.Drawing. Font(nom_fue, tam_fue, TextBox1.Font.Style) EN EL LISTBOX tam_fue = ListBox1.Text TextBox1.Font = New System.Drawing.Font(nom_fue, tam_fue, TextBox1.Font.Style) EN CADA RADIOBUTTON

If CheckBox2.Checked Then TextBox1.Font = New System.Drawing.Font (TextBox1.Font, TextBox1.Font.Style Or FontStyle.Italic) Else If CheckBox3.Checked Then If CheckBox1.Checked Then TextBox1.Font = New System.Drawing.Font (TextBox1.Font, FontStyle.Underline Or FontStyle.Bold) Else TextBox1.Font = New System.Drawing.Font (TextBox1.Font, FontStyle.Underline) End If Else If CheckBox1.Checked Then TextBox1.Font = New System.Drawing.Font (TextBox1.Font, FontStyle.Bold) End If End If If Not CheckBox3.Checked Then If Not CheckBox1.Checked Then TextBox1.Font = New System.Drawing.Font (TextBox1.Font, FontStyle.Regular) End If End If End If If CheckBox3.Checked Then TextBox1.Font = New System.Drawing.Font (TextBox1.Font, TextBox1.Font.Style Or FontStyle.Underline) Else If CheckBox1.Checked Then If CheckBox2.Checked Then TextBox1.Font = New System.Drawing.Font (TextBox1.Font, FontStyle.Bold Or FontStyle.Italic) Else TextBox1.Font = New System.Drawing.Font (TextBox1.Font, FontStyle.Bold) End If Else If CheckBox2.Checked Then TextBox1.Font = New System.Drawing.Font (TextBox1.Font, FontStyle.Italic) End If End If If Not CheckBox1.Checked Then If Not CheckBox2.Checked Then TextBox1.Font = New System.Drawing.Font (TextBox1.Font, FontStyle.Regular) End If End If End If

TextBox1.ForeColor = System.Drawing.Color .Red


EN LOS CHECKBOXS If CheckBox1.Checked Then TextBox1.Font = New System.Drawing.Font (TextBox1.Font, TextBox1.Font.Style Or FontStyle.Bold) Else If CheckBox2.Checked Then If CheckBox3.Checked Then TextBox1.Font = New System.Drawing.Font (TextBox1.Font, FontStyle.Italic Or FontStyle.Underline) Else TextBox1.Font = New System.Drawing.Font (TextBox1.Font, FontStyle.Italic) End If Else If CheckBox3.Checked Then TextBox1.Font = New System.Drawing.Font (TextBox1.Font, FontStyle.Underline) End If End If If Not CheckBox2.Checked Then If Not CheckBox3.Checked Then TextBox1.Font = New System.Drawing.Font (TextBox1.Font, FontStyle.Regular) End If End If End If

FUNCION QUE ACEPTA SOLO NUMEROS Public Function solo_numero(ByVal dato As Boolean, ByVal alfa As String, ByVal control As TextBox) As Boolean If Not dato Then If Asc(alfa) = 8 Then

solo_numero = False Else solo_numero = True End If End If End Function

EN EL KEYPRESS DE TEXTBOX e.Handled = solo_numero(Char.IsNumber(e.KeyChar), e.KeyChar, TextBox3) LISTAS ENLAZADAS Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load lblmensaje.Text = "Numero Total de cursos en la Lista1 : (" + _ Trim(Str(lst1.Items.Count)) & " elementos) y la Lista 2 : (" & _ Trim(Str(lst2.Items.Count)) & " elementos)" End Sub Private Sub btnanadir_Click(sender As System.Object, e As System.EventArgs) Handles btnanadir.Click lst1.Items.Add(txtcurso.Text) txtcurso.Text = "" txtcurso.Focus() End Sub Private Sub txtcurso_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtcurso.KeyPress If e.KeyChar = ChrW(13) Then btnanadir_Click(Nothing, Nothing) End If End Sub Sub lista_elementos(ByVal celementos As Integer, ByVal lorigen As ListBox, ByVal ldestino As ListBox) If celementos < 0 Then Exit Sub If celementos = lorigen.Items.Count Then Dim i As Integer For i = 0 To lorigen.Items.Count - 1 ldestino.Items.Add(lorigen.Items.Item(i)) Next lorigen.Items.Clear() Else ldestino.Items.Add(lorigen.Text) lorigen.Items.RemoveAt(celementos) End If lblmensaje.Text = "Numero Total de cursos en la Lista1 : (" + _ Trim(Str(lst1.Items.Count)) & " elementos) y la Lista 2 : (" & _ Trim(Str(lst2.Items.Count)) & " elementos)" End Sub

Private Sub txtcurso_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtcurso.TextChanged End Sub Private Sub btnagregar_Click(sender As System.Object, e As System.EventArgs) Handles btnagregar.Click Call lista_elementos(lst1.SelectedIndex, lst1, lst2) End Sub Private Sub btnquitar_Click(sender As System.Object, e As System.EventArgs) Handles btnquitar.Click Call lista_elementos(lst2.SelectedIndex, lst2, lst1) End Sub Private Sub btnagretodo_Click(sender As System.Object, e As System.EventArgs) Handles btnagretodo.Click Call lista_elementos(lst1.Items.Count, lst1, lst2) End Sub Private Sub btnquittodo_Click(sender As System.Object, e As System.EventArgs) Handles btnquittodo.Click Call lista_elementos(lst2.Items.Count, lst2, lst1) End Sub

EN CLASES CODIGO Private a, b, c, d As Integer Public tot As Double

Public Sub New(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer, ByVal d As Integer) Me.a = a Me.b = b Me.c = c Me.d = d End Sub Public Function geta() As Integer Return a End Function Public Function getb() As Integer Return b End Function Public Function getc() As Integer Return c End Function Public Function getd() As Integer Return d End Function Public Function gettot() As Integer Return tot End Function Public Function Factorial(ByVal a As Integer) As Integer Dim fac As Integer fac = 1 For i = 1 To a fac *= i Next Return fac End Function

Public Sub Mostrar() tot = Factorial(geta()) + Factorial(getb()) + Factorial(getc()) + Factorial(getd()) End Sub Dim objeto As Class1 = New Class1(CInt(TextBox1.Text), CInt(TextBox2.Text), CInt(TextBox3.Text), CInt(TextBox4.Text)) objeto.Mostrar() MsgBox("La suma de Factoriales= " & objeto.gettot(), vbQuestion, "Factoriales")

Public Sub Mostrar() MsgBox("Los datos Ingresados son " & vbCrLf & vbCrLf & _ "Nombre : " & getnom() & vbCrLf & _ "Dureccion : " & getdir() & vbCrLf & _ "Telefono : " & gettel(), vbInformation, "Aviso") End Sub Dim objeto As Class1 = New Class1() objeto.Lectura(TextBox1.Text, TextBox2.Text, TextBox3.Text) objeto.Mostrar() EN UNA SUB CLASE CODIGO Inherits PRIMERO Public Sub New(ByVal a1 As String, ByVal a2 As String, ByVal a3 As String) MyBase.New(a1, a2, a3) End Sub Public Overloads Sub Mostrar() MsgBox("Los datos ingresados en " + " la clase segundo son" + _ vbCrLf + MyBase.getd1() + _ vbCrLf + MyBase.getd2() + _ vbCrLf + MyBase.getd3(), vbInformation, "Aviso") End Sub Public Sub Mensaje() MsgBox("El Uso de las clases son divertidas", vbQuestion, "Ventanilla") End Sub METODO DE ORDENAMIENTO BURBUJA ReDim arre(n) For i = 0 To n - 1 arre(i) = ListBox1.Items.Item(i) Next If RadioButton1.Checked = True Then For i = 0 To n - 2 For j = i + 1 To n - 1 If arre(i) < arre(j) Then aux = arre(i) arre(i) = arre(j) arre(j) = aux End If Next j Next i ElseIf RadioButton2.Checked = True Then For i = 0 To n - 2 For j = i + 1 To n - 1 If arre(i) > arre(j) Then aux = arre(i) arre(i) = arre(j) arre(j) = aux End If Next j Next i End If ListBox1.Items.Clear() For i = 0 To n - 1 ListBox1.Items.Add(arre(i)) Next

También podría gustarte