How to populate listbox with textbox?

VB NET Textbox code duplication?

  • Is there a way to maker this code work in a textbox instead of a Listbox? I am trying to stop duplication in one of my textbox for Member ID to make it so the number entered if it already exists in my access table it will not accept it memID = Val(TextBox1.Text) If Cnt1 = 0 Then Flag1 = 0 Else For i = 0 To Cnt1 - 1 MsgBox("Member ID Already exists") 'MsgBox(memID & Arr(i)) If memID = Arr(i) Then Flag1 = 1 End If Next End If If Flag1 = 1 Then Flag1 = 0 TextBox1.Clear() TextBox1.Focus() Else Arr(Cnt1) = memID 'ListBox1.Items.Add(memID) 'ListBox2.Items.Add(Arr(Cnt1)) MsgBox("added") Cnt1 = Cnt1 + 1 TextBox1.Clear() TextBox1.Focus() End If Thank You

  • Answer:

    You attempted to incorporate the code I developed for another question . This code will not work, unless it is modified to do what you are attempting to do. You even left the message boxes I installed to test the code. If you will edit your question to include the name and path to your Access data base, when I get time, I will modify the code to fir your purpose. TexMav

Laura at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

memID = Val(TextBox1.Text) If Cnt1 = 0 Then Flag1 = 0 Else For i = 0 To Cnt1 - 1 MsgBox("Member ID Already exists") 'MsgBox(memID & Arr(i)) If memID = Arr(i) Then Flag1 = 1 End If Next End If If Flag1 = 1 Then Flag1 = 0 TextBox1.Clear() TextBox1.Focus() Else Arr(Cnt1) = memID 'TextBox1.Text = memID 'TextBox2.Text = (Arr(Cnt1)) MsgBox("added") Cnt1 = Cnt1 + 1 TextBox1.Clear() End If

Trollface.jpg

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.