| | |
Problem with listboxs
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2008
Posts: 60
Reputation:
Solved Threads: 0
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
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

vb Syntax (Toggle Plain Text)
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
•
•
Join Date: Jun 2009
Posts: 132
Reputation:
Solved Threads: 13
for button1 instead of using for loop try using this
VB.NET Syntax (Toggle Plain Text)
if (textbox1.text.contains = "f") .......... ............ end if
•
•
Join Date: Jun 2009
Posts: 132
Reputation:
Solved Threads: 13
well didnt understand your code for button 4
hope this helps
hope this helps
VB.NET Syntax (Toggle Plain Text)
if salary < 1000 rightlistbox1.item.remove(".......") otherlistbox.item.add("....") end if
![]() |
Similar Threads
- Problem with Windows Update and WinXP (Web Browsers)
- Installing Windows 98 On VMware. Floppy problem (Windows 95 / 98 / Me)
- Windows XP keeps restarting since a new video card (Windows NT / 2000 / XP)
- Redhat Linux 6.2 - ipop3d problem? (*nix Software)
- Problem with T720 (Cellphones, PDAs and Handheld Devices)
- Connection Problems (Networking Hardware Configuration)
- Encoding (Unicode) problem in IE 6.0 (Web Browsers)
- .htaccess mod_rewrite problem (Linux Servers and Apache)
- Javascript/HTML problem!!! (JavaScript / DHTML / AJAX)
Other Threads in the VB.NET Forum
- Previous Thread: how to get value of combobox using sql
- Next Thread: datagridvew
| Thread Tools | Search this Thread |
.net .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons c# center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dropdownlist excel file-dialog folder ftp generatetags google gridview hardcopy image images inline insert intel internet listview mobile monitor ms net networking output passingparameters peertopeervideostreaming picturebox picturebox1 plugin port print printing problem problemwithinstallation project reports" save savedialog searchbox searchvb.net select serial server soap sql table tcp text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





