Problem with listboxs

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2008
Posts: 60
Reputation: gispe is an unknown quantity at this point 
Solved Threads: 0
gispe gispe is offline Offline
Junior Poster in Training

Problem with listboxs

 
0
  #1
Jul 16th, 2009
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


  1.  
  2. Public Class Form1
  3. Dim sueldo(49) As Double
  4. Dim nombre(49) As String
  5. Dim indice_sueldo As Integer
  6. Dim indice_nombre, lba, lbb, d As Integer
  7. Dim vec(49), cont As Integer
  8. Dim indice As Integer
  9.  
  10.  
  11.  
  12. Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
  13.  
  14. End Sub
  15. Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
  16.  
  17. End Sub
  18.  
  19. Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
  20.  
  21. End Sub
  22.  
  23. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  24. If txtNombre.Text = Nothing Then
  25. MsgBox("Ingrese nombre")
  26. txtNombre.Focus()
  27. Else
  28. If txtSueldo.Text = Nothing Then
  29. MsgBox("Ingrese el sueldo")
  30. txtSueldo.Focus()
  31. Else
  32. If Not IsNumeric(txtSueldo.Text) Then
  33. MsgBox("ERROR: Sueldo [solo números]")
  34. txtSueldo.Focus()
  35. txtSueldo.SelectAll()
  36. Else
  37. If IsNumeric(txtNombre.Text) Then
  38. MsgBox("ERROR: Nombre [Solo letras]")
  39. txtNombre.Focus()
  40. txtNombre.SelectAll()
  41. Else
  42.  
  43. ListBox1.Items.Add(txtNombre.Text & " - " & txtSueldo.Text)
  44. sueldo(lba) = Convert.ToDouble(txtSueldo.Text)
  45. lba += 1
  46. 'indice = Convert.ToDouble(txtSueldo.Text)
  47. 'sueldo(tope_sueldo) = tope_sueldo + tope_sueldo
  48. End If
  49. End If
  50. End If
  51. End If
  52.  
  53.  
  54.  
  55.  
  56. End Sub
  57.  
  58. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  59. If txtNombre.Text = Nothing Then
  60. MsgBox("Ingrese el nombre")
  61. txtNombre.Focus()
  62. Else
  63. If txtSueldo.Text = Nothing Then
  64. MsgBox("Ingrese el sueldo")
  65. txtSueldo.Focus()
  66. Else
  67. If Not IsNumeric(txtSueldo.Text) Then
  68. MsgBox("ERROR: Sueldo [solo números]")
  69. txtSueldo.Focus()
  70. txtSueldo.SelectAll()
  71. Else
  72. If IsNumeric(txtNombre.Text) Then
  73. MsgBox("ERROR: Nombre [Solo letras]")
  74. txtNombre.Focus()
  75. txtNombre.SelectAll()
  76. Else
  77. ListBox2.Items.Add(txtNombre.Text & " - " & txtSueldo.Text)
  78. lbb = d
  79. sueldo(lbb) = Convert.ToDouble(txtSueldo.Text)
  80. lbb += 1
  81. End If
  82. End If
  83. End If
  84. End If
  85.  
  86.  
  87.  
  88.  
  89. End Sub
  90.  
  91. Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  92. ListBox2.Items.Add(ListBox1.SelectedItem)
  93. ListBox1.Items.RemoveAt(indice)
  94. End Sub
  95.  
  96. Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
  97. ListBox1.Items.Add(ListBox2.SelectedItem)
  98. ListBox2.Items.RemoveAt(indice)
  99. End Sub
  100.  
  101. Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
  102. ListBox1.Items.RemoveAt(indice)
  103. End Sub
  104.  
  105. Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
  106. ListBox2.Items.RemoveAt(indice)
  107. End Sub
  108.  
  109. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  110.  
  111. Dim s, n As Int32
  112. sueldo(s) = Convert.ToDouble(txtSueldo.Text)
  113. ListBox2.Text() = s
  114. nombre(n) = txtNombre.Text
  115.  
  116.  
  117.  
  118. If sueldo(s) < 1000 Then
  119. For j As Int32 = 0 To sueldo.Count - 1
  120.  
  121. indice_sueldo += 1
  122. Next
  123. 'Else
  124. 'MsgBox ("No ahi sueldos menores que 1000")
  125. End If
  126.  
  127. For i As Int32 = 0 To indice_sueldo - 1
  128. ListBox1.Items.Add(Convert.ToString(nombre(i) & " - " & sueldo(i)))
  129. ListBox2.Items.Remove(sueldo(i))
  130. Next
  131.  
  132.  
  133.  
  134. End Sub
  135.  
  136. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  137. 'MsgBox("Atención: no pude hacer esta parte en el codigo va a ver que deje el codigo en comentario")
  138.  
  139. Dim i As Integer = 0
  140.  
  141. nombre(i) = txtNombre.Text
  142. i = i + 1
  143. For j As Int32 = 0 To nombre.Count - 1
  144.  
  145. If nombre(j) = "f" Then
  146. ListBox2.Items.Add(nombre(j) & " - " & sueldo(j))
  147. 'Else
  148. ' MsgBox("No ahi elementos que contegan la letra f")
  149. End If
  150. Next
  151.  
  152. End Sub
  153.  
  154. Private Sub TextBox1_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNombre.TextChanged
  155.  
  156. End Sub
  157.  
  158. Private Sub txtSueldo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSueldo.TextChanged
  159.  
  160. End Sub
  161. End Class
Attached Files
File Type: doc Recuperatorio via mail 1er Parcial EnglishVersion.doc (51.0 KB, 0 views)
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 132
Reputation: babbu has a little shameless behaviour in the past 
Solved Threads: 13
babbu babbu is offline Offline
Junior Poster

Re: Problem with listboxs

 
0
  #2
Jul 17th, 2009
for button1 instead of using for loop try using this
  1. if (textbox1.text.contains = "f")
  2. ..........
  3. ............
  4. end if
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 132
Reputation: babbu has a little shameless behaviour in the past 
Solved Threads: 13
babbu babbu is offline Offline
Junior Poster

Re: Problem with listboxs

 
0
  #3
Jul 17th, 2009
well didnt understand your code for button 4
hope this helps
  1. if salary < 1000
  2. rightlistbox1.item.remove(".......")
  3. otherlistbox.item.add("....")
  4. end if
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC