Adding empty space to listbox?

G

Guest

Hi EveryBody:

I made project by Vb.Net which consist the following items:

1\ Textbox
2\Button
3\Listbox

When you write any thing in the textbox and press the button any text
written in the textbox will be added to the listbox, but i figure that when
you just press the space button in the keyboard for how long you want, that
empty space in the textbox will be added to the listbox when you press the
button.

So any one can help and give me any hint or direction how can I prevent
adding any empty space in the textbox to the listbox?

Any help will be appreciated

regard's

Husam
 
C

Cor Ligthert [MVP]

Husam,

It seems quiet normal what you tell.

I think that if it was my problem that I would use the Trim and than look if
the lenght of the text after that was longer than 0.

MyString = Trim(MyTextbox.Text)
If MyString.Length > 0
'procedure to add the mystring or the mytextbox.text to the listbox
End if

In my opinion is with mystring text than also direct nicer in your listbox.
(However there can be reason not tot do that)

I hope this helps,

Cor
 
H

Herfried K. Wagner [MVP]

Husam said:
When you write any thing in the textbox and press the button any text
written in the textbox will be added to the listbox, but i figure that
when
you just press the space button in the keyboard for how long you want,
that
empty space in the textbox will be added to the listbox when you press the
button.

So any one can help and give me any hint or direction how can I prevent
adding any empty space in the textbox to the listbox?

\\\
If Len(Trim(Me.TextBox1.Text)) > 0 Then
Me.ListBox1.Items.Add(Me.TextBox1.Text)
Else
With Me.TextBox1
.Text = ""
.Focus()
End With
End If
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top