473,387 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Adding empty space to listbox?

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
Nov 21 '05 #1
3 4320
Validate the contents of the textbox before adding it the listbox.
"Husam" <Hu***@discussions.microsoft.com> wrote in message
news:D9**********************************@microsof t.com...
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

Nov 21 '05 #2
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
Nov 21 '05 #3
"Husam" <Hu***@discussions.microsoft.com> schrieb:
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
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: Xah Lee | last post by:
sometimes i wish to add white space in <p> as to achived effects similar to tab. what should i do? using empty image seems the sure way but rather complicated. (and dosen't change size with...
0
by: Chris Millar | last post by:
I have a user control that i wish to extend to change the date when the user selects the numeric up down button. The code explains itself, hope someone can help. any ideas appreaciated.. ...
3
by: Pafo007 | last post by:
Hi. I've built a small window, with some buttons and labels, and one listbox. During design time, I put five lines in the listbox and launch the program: the listbox appears empty! I can select...
4
by: Harold | last post by:
I have read the following article http://www.4guysfromrolla.com/webtech/073101-1.shtml. I added the empty selection as the first option. When I click submit without choosing anything it does not...
6
by: Papa.Coen | last post by:
I've just spend a lot of time solving the following problem: I used dotNet 2.0 / Visualstudio 2005 / C# / aspx, enable viewstate is set on all controls. I have 2 listboxes; the left contains items...
14
by: Paul_Madden via DotNetMonster.com | last post by:
Basically I have a listbox to which I add simple STRING items- I have a progress bar which I increment whenever I populate another portion of the complete set of items I wish to add. What I observe...
1
by: bill | last post by:
I need to be able to dynamically add items to a <asp:listbox> (or HTML <select runat=server>) using clientside javascript, and retrieve the items when the page is posted back. I use this code to...
4
by: Dave | last post by:
I recently found out that the RequiredFieldValidator works differently for a ListBox than I needed; it checks to see if a row is selected, rather than checking to see if the listbox is empty. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.