| | |
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: 143
Reputation:
Solved Threads: 14
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: 143
Reputation:
Solved Threads: 14
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 |
Tag cloud for VB.NET
.net .net2008 2008 access advanced application array basic beginner browser button buttons center click client code combo convert cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic eclipse excel exists fade filter forms function html images input lib listview map mobile module msaccess net number objects open panel pdf picturebox picturebox2 port position print printing problem read regex remove right-to-left save search searchvb.net serial settings shutdown socket sorting sqldatbase sqlserver survey temperature textbox timer timespan transparency txttoxmlconverter user usercontol validation vb vb.net vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web webbrowser winforms winsock wpf wrapingcode xml year





