473,978 Members | 35,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

a button that adds text to a textbox

5 New Member
hello! i have a textbox, and 2 buttons. this is what i would like:

when i click button 1, "1" is added to the textbox. when i click button 2, "2" is added to the textbox.

i have tried to do this myself, but when ever i click one of the buttons, it clears the digit that is already in the textbox, and then adds a new digit. i want it to keep adding digit after digit. eg. if i press button 1 three time, then button 2 twice, the textbox shows "11122". then if i press button 1 again, it adds a one to the end of the text, making it read "111221", etc.

any help would be much appreicated!
Mar 10 '07 #1
5 1713
markmcgookin
648 Recognized Expert Contributor
hello! i have a textbox, and 2 buttons. this is what i would like:

when i click button 1, "1" is added to the textbox. when i click button 2, "2" is added to the textbox.

i have tried to do this myself, but when ever i click one of the buttons, it clears the digit that is already in the textbox, and then adds a new digit. i want it to keep adding digit after digit. eg. if i press button 1 three time, then button 2 twice, the textbox shows "11122". then if i press button 1 again, it adds a one to the end of the text, making it read "111221", etc.

any help would be much appreicated!
No problem!

If your textbox was called TextBox1 then after

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.  
for each button put

Expand|Select|Wrap|Line Numbers
  1. TextBox1.Text = ""
  2.  
Then under that should be your code to add the text in.

Hope that helps!
Mar 10 '07 #2
devonknows
137 New Member
Just another quick suggestion it its any easier in your Command#_Click sub section you could just enter something as simple as

Expand|Select|Wrap|Line Numbers
  1. TextBox1.Text = TextBox1.Text & 2 'For Command1
  2. TextBox1.Text = TextBox1.Text & 1 'For Command2
  3.  
Not Sure you would find easier to work with but a quick demo is below
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.     Text1.Text = Text1.Text & 1
  3. End Sub
  4.  
  5. Private Sub Command2_Click()
  6.     Text1.Text = Text1.Text & 2
  7. End Sub
  8.  
Kind Regards
Devon.
Mar 10 '07 #3
manojkapparath
5 New Member
hello! i have a textbox, and 2 buttons. this is what i would like:

when i click button 1, "1" is added to the textbox. when i click button 2, "2" is added to the textbox.

i have tried to do this myself, but when ever i click one of the buttons, it clears the digit that is already in the textbox, and then adds a new digit. i want it to keep adding digit after digit. eg. if i press button 1 three time, then button 2 twice, the textbox shows "11122". then if i press button 1 again, it adds a one to the end of the text, making it read "111221", etc.

any help would be much appreicated!
Suppose Your TextBox be Text1.
When you press a Button, Say Cmd_One (for 1)
Write the Code
Text1.Text = Text1.Text & "1"

When you press a Button, Say Cmd_Two (for 2)
Write the Code
Text1.Text = Text1.Text & "2"

Now it will Work Effectively.
Mar 10 '07 #4
markmcgookin
648 Recognized Expert Contributor
No problem!

If your textbox was called TextBox1 then after

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.  
for each button put

Expand|Select|Wrap|Line Numbers
  1. TextBox1.Text = ""
  2.  
Then under that should be your code to add the text in.

Hope that helps!

Hehe, I just re-read your post and realised I gave you the totally wrong answer....

lol something nice and easy would be

Expand|Select|Wrap|Line Numbers
  1. Dim Temp as String
  2. Temp = TextBox1.Text
  3. Temp = Temp & 1     'For button 1 and ... Temp = Temp & 2 for button 2
  4. TextBox1.Text = Temp
  5.  
Mar 10 '07 #5
iDaz
5 New Member
WOW thank you very much everyone for your help!! i really do appreciate it! you've just helped me complete an assignment for my IT course! thank you all!
Mar 13 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
15748
by: dskillingstad | last post by:
I'm trying to assign a custom value to a textbox. Here's what I have. I've created a module and "default value" code for a textbox which generates a custom auto-number (yyyy-0000) when a New Record button is clicked. The code checks the table for the highest value and then assigns 1 and inserts the value. I have a second text box which needs the same type of custom auto-number which has to be generated from a second command button. ...
2
13285
by: techfuzz | last post by:
I scoured this group and others looking for the best way to disable a button after the first click to prevent multiple submissions, but never did find anything that worked like they said it would. I went ahead and wrote my own bit of code so I'm sharing it here for everyone. Even though it doesn't really disable the button by greying it out, it prevents the multiple submissions which it what I was attempting to prevent all along. ...
0
5765
by: Oz | last post by:
Hi Using VS.NET 2003, Windows XP SP1, We have a page which has been developed using ASP.NET. On it, is a button which when clicked is supposed to add some data to a table. When the button is selected, it causes the ServerClick event to be called twice. Here's the code: You'll see that there are two grids on the page, and that the function SetupDataGrid populates data to the two grid. There are also
2
8749
by: Chris Fink | last post by:
This should be relatively simple but I am unable to find an asp:button tag in a datalist footer. I have tried it numerous ways including the FindControl method from the many events that the DataList exposes and the result is always null (I've determined the OnItemDataBound event will not find the footer controls). I understand that I have to navigate the datalist object tree, but I feel like it is a guessing game and am hesitant to do it...
1
3649
by: RUIZCJ | last post by:
Hi, I'm at my wits end!!! I have the following code. The submit button works on my home computer but when I copy the dll and the ASPX file to my host provider, the button does NOT fire. TIA RuizCJ
0
2106
by: loga123 | last post by:
Hi All, I am very new to .net and trying to develop a small application. I am using asp .net 2.0. I have a table control (server) in my code that has header row like this. <asp:Table id="Table1" GridLines="Both"
2
3904
by: toddw607 | last post by:
Hi all! I am attempting to bring an SQL Server table into ASP.NET using the datagrid . I have set all cells to be a text box by which the user can just click on and edit the cell. I have a save button and when I click the save button the page reloads and the new data is in the cell, however when I close out and come back in the data is no longer there. I have a databind() subroutine which includes a postback included within my code for...
1
7050
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the page has multiple button such login page with a search function somewhere around, then it's not respond properly. I have attached a brief example of two text boxes and two button. When ever a key is press on textbox one, I want to trigger...
1
1665
by: Forumtroll | last post by:
I have a Web User Control that parses an XML file and renders a Form based on the XML. The problem is that I create a button on the bottom of the form that will fire off a subscribeable event, but somehow the button never seem to fire that particular event. The code is attached below. using System; using System.Collections;
0
10357
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
11832
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11591
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
10920
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
10087
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7620
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6423
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...
1
5162
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
4737
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.