Hi!!
I made a program, but Im having a problem with the button 4_click
and the button 1_click, the work, but not the way they should.
button_4 should pass the salarys that are under 1000 to the other listbox, delete them from the right listbox. And what it does, is: pass the data, doesnt delete them, and adds 0 at the end.
button_1: should look for the names that have an "F" somewhere in them, and pass them to the other listbox. But this button doesnt work at all :(
i've attached a txt where is what i have to do... (if needed)
thanks in advanced :D
Public Class Form1
Dim sueldo(49) As Double
Dim nombre(49) As String
Dim indice_sueldo As Integer
Dim indice_nombre, lba, lbb, d As Integer
Dim vec(49), cont As Integer
Dim indice As Integer
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If txtNombre.Text = Nothing Then
MsgBox("Ingrese nombre")
txtNombre.Focus()
Else
If txtSueldo.Text = Nothing Then
MsgBox("Ingrese el sueldo")
txtSueldo.Focus()
Else
If Not IsNumeric(txtSueldo.Text) Then
MsgBox("ERROR: Sueldo [solo números]")
txtSueldo.Focus()
txtSueldo.SelectAll()
Else
If IsNumeric(txtNombre.Text) Then
MsgBox("ERROR: Nombre [Solo letras]")
txtNombre.Focus()
txtNombre.SelectAll()
Else
ListBox1.Items.Add(txtNombre.Text & " - " & txtSueldo.Text)
sueldo(lba) = Convert.ToDouble(txtSueldo.Text)
lba += 1
'indice = Convert.ToDouble(txtSueldo.Text)
'sueldo(tope_sueldo) = tope_sueldo + tope_sueldo
End If
End If
End If
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If txtNombre.Text = Nothing Then
MsgBox("Ingrese el nombre")
txtNombre.Focus()
Else
If txtSueldo.Text = Nothing Then
MsgBox("Ingrese el sueldo")
txtSueldo.Focus()
Else
If Not IsNumeric(txtSueldo.Text) Then
MsgBox("ERROR: Sueldo [solo números]")
txtSueldo.Focus()
txtSueldo.SelectAll()
Else
If IsNumeric(txtNombre.Text) Then
MsgBox("ERROR: Nombre [Solo letras]")
txtNombre.Focus()
txtNombre.SelectAll()
Else
ListBox2.Items.Add(txtNombre.Text & " - " & txtSueldo.Text)
lbb = d
sueldo(lbb) = Convert.ToDouble(txtSueldo.Text)
lbb += 1
End If
End If
End If
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
ListBox2.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.RemoveAt(indice)
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
ListBox1.Items.Add(ListBox2.SelectedItem)
ListBox2.Items.RemoveAt(indice)
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
ListBox1.Items.RemoveAt(indice)
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
ListBox2.Items.RemoveAt(indice)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim s, n As Int32
sueldo(s) = Convert.ToDouble(txtSueldo.Text)
ListBox2.Text() = s
nombre(n) = txtNombre.Text
If sueldo(s) < 1000 Then
For j As Int32 = 0 To sueldo.Count - 1
indice_sueldo += 1
Next
'Else
'MsgBox ("No ahi sueldos menores que 1000")
End If
For i As Int32 = 0 To indice_sueldo - 1
ListBox1.Items.Add(Convert.ToString(nombre(i) & " - " & sueldo(i)))
ListBox2.Items.Remove(sueldo(i))
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'MsgBox("Atención: no pude hacer esta parte en el codigo va a ver que deje el codigo en comentario")
Dim i As Integer = 0
nombre(i) = txtNombre.Text
i = i + 1
For j As Int32 = 0 To nombre.Count - 1
If nombre(j) = "f" Then
ListBox2.Items.Add(nombre(j) & " - " & sueldo(j))
'Else
' MsgBox("No ahi elementos que contegan la letra f")
End If
Next
End Sub
Private Sub TextBox1_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNombre.TextChanged
End Sub
Private Sub txtSueldo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSueldo.TextChanged
End Sub
End Class