473,396 Members | 1,702 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,396 software developers and data experts.

Plus & Minus Buttons

Is it as easy to implement into my form as I think?

I have a text field called Qty in a form, and I would like to have a plus (+) and Minus (-) buttons to increase or decrease the number in the text field, is this possible and easy?

I have found a example online but it doesn't work!

Could someone be kind enough to help.

Thank You
Dec 5 '11 #1

✓ answered by jimatqsi

Perhaps it is not the example that does not work but your implementation of the example. If you share your work with us we could help you with that.

It will be very simple. Each button will have have one statement in the OnClick event for the button, something like:
Expand|Select|Wrap|Line Numbers
  1. me!nameoftextbox = me!nameoftextbox-1
or +1 instead of -1

plus you may want to add some error handling.

Jim

6 6835
jimatqsi
1,271 Expert 1GB
Perhaps it is not the example that does not work but your implementation of the example. If you share your work with us we could help you with that.

It will be very simple. Each button will have have one statement in the OnClick event for the button, something like:
Expand|Select|Wrap|Line Numbers
  1. me!nameoftextbox = me!nameoftextbox-1
or +1 instead of -1

plus you may want to add some error handling.

Jim
Dec 5 '11 #2
Hi there

This is the code I found:

Expand|Select|Wrap|Line Numbers
  1.     If KeyCode = 107 Then
  2.         Me.Text1 = Me.Text1 + 1
  3.         KeyCode = 0
  4.     ElseIf KeyCode = 109 Then
  5.         Me.Text1 = Me.Text1 - 1
  6.         KeyCode = 0
  7. End If
I changed the text1 to the name on my field
Dec 5 '11 #3
NeoPa
32,556 Expert Mod 16PB
That code doesn't look like it's for buttons Will. If I were a guessing man I'd say that was trying to handle keystrokes. Unfortunately much of the code that would provide context and clues is missing. Do you think you could include the whole procedure, and perhaps confirm how this is supposed to be working from the operator's perspective.
Dec 6 '11 #4
jimatqsi, thanks for you example it works great, you say about error handling, would it be easy enough to stop the number going into minus numbers so it stops at '0'?

NeoPa there was much info with the example I posted, the title just said Plus & Minus buttons, but no after some reading, I guess they were looking at using the keyboards +, - buttons!
Dec 6 '11 #5
jimatqsi
1,271 Expert 1GB
Will, as for the logical limits on the values, that will be determined by your application's needs. What if there is nothing in the box to begin with? That is partly what I was referring to. But you should also add generic error handling that should be in every routine you make, something like this:
Expand|Select|Wrap|Line Numbers
  1. on error goto ErrLabelName  ' put this as 1st instruction
  2. ' then your routine should end with this:
  3. on error goto 0
  4. Exit Sub or Exit Function
  5.  
  6. ErrLabelName:
  7.    msgbox err.number & " " & err.description
  8.    resume next
  9.  
  10. end sub or end function
Jim
Dec 6 '11 #6
NeoPa
32,556 Expert Mod 16PB
Keystrokes are much harder to make work sensibly. When you click on the button it's always clear what your intention is, but when you hit '-' for instance, you may be trying to decrement that paricular figure, or you may be typing something in another field EG. "I bought my groceries at the Co-Op". Your code (and design) would need to handle that.
Dec 6 '11 #7

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

Similar topics

2
by: Ethel Aardvark | last post by:
I have a query which runs fine in SQL*Plus but which will not compile into a packaged procedure (claiming that the table can not be found): SELECT DISTINCT Folder_ID INTO l_RootID -- remove...
0
by: sophocles the wise | last post by:
automatically post data & click buttons on sequence of web pages with AxWebBrowser Hi, I need to post stuff everyday to a website and am working on a VB program to do this for me. I am a...
1
by: Bibic0711 | last post by:
I am having problem on following situation, any comments are welcome. I have this table A which contents most of the data, that needs to be query based on a name field in table B and was linked...
0
by: bj7lewis | last post by:
I have two modal dlg forms that are invoked(seperately) by a main form but the two modal dlg forms don't close when clicking the OK & Cancel buttons setup as below... Here the setup... //In...
1
by: Robert W. | last post by:
I've added a toolbar to my WinForms app and would like to have standard graphical buttons for the standard things (ie. New, Open, Close, Save, etc.) But I have a less well known featured called...
0
by: Steve Kallal | last post by:
I have a DataGrid with an EditCommandColumn column set to a type of PushButton. I want to set set CssClass on these buttons and cannot without using code-behind code on the ItemDataBound event. The...
16
by: browntown | last post by:
so I have this application I'm nearly finished with. The only thing the client has requested is the ability to submit the form by pressing "enter". I didn't think this would be a huge pain in the...
1
by: jmdolinger | last post by:
Hi all, Has anyone ever seen the following Javascript problem (in IE). I'm trying to set up a hash of rating values to integers (which I'll then use to sort an array of ratings). It looks like...
0
by: hime | last post by:
hi all; I have a web form to enter data in my table i am trying to add a Next & previous buttons but it's not working am using (.Net C# and MySql DB). and in the form I used textboxs to show the...
4
by: tamnguyet | last post by:
I have n days and a date, I want a date plus(or minus) to n days.How can I do that in javascript
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...
0
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...
0
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...
0
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,...

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.