473,749 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4343
Validate the contents of the textbox before adding it the listbox.
"Husam" <Hu***@discussi ons.microsoft.c om> wrote in message
news:D9******** *************** ***********@mic rosoft.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***@discussi ons.microsoft.c om> 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.Tex tBox1.Text)) > 0 Then
Me.ListBox1.Ite ms.Add(Me.TextB ox1.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
24005
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 font) Woudl some of the space character in unicode work? (my html files uses unicode) Xah
0
1924
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.. Chris. code :
3
2133
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 the first five lines, but they become blue (=selected) without any text. I tried to feel the listbox during runtime, but I got the same result. If I catch listbox1.SelectedItem.ToString() when one of the 5 lines is correctly selected (but always...
4
2308
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 return my empty string but the 2nd value in listbox. When the page reloads it selects the 2nd option by default even thou my Empty field is in the list. What do I have to do to get the empty field and databound data to act as one?
6
3658
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 that can be (dynamically) added to the right box. Adding the first item went fine, it shows up in the right box. Adding the second item resulted in losing _every_ control following the right box. 'View source' reveiled that the rendering of the...
14
18748
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 is that as more and more are added, population of the list box takes longer and longer. ie the first 10th of the item set are added much much quicker than the last 10th. THis occurs with about 40,000 listbox items. My worry is the listbox may...
1
12790
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 add the option to the listbox. It works for <select> or <asp:listbox> controls. var opt = document.CreateElement("OPTION"); opt.text = "test"; opt.value="test";
4
9382
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 tried using a CustomValidator but it does not seem to be firing (I have e.false in the validation function but still no intervention). Does the CustomValidator also require that a row is selected? Can I use validators for this requirement or do I...
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9388
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.