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

How to create an in form Calculater

I would like to start by saying I have limited programming knowledge except for one university course in C++ that I took 5 years ago. therefore I have an understanding of syntax and how they're supposed to work together but may need help in actually implementing it.

Essentially I have a bunch of different fabrics coming off a line with the possibility of various defects in each fabric. I want the operator to - in a form regarding said fabric - be able to enter the total number of defects of a type, total number of fabrics off the line, and therefore get an efficiency of the line.

I realize how this is explained, this could be solved with a simple input of both with an expression however in case the database is to evolve at some point I would like a basic calculator handy on the form.

In this way they can enter anynumber_01 , any operator, anynumber_02, equals, and then the textbox displays the result. Upon saving the form the displayed textbox value is recorded in a record.
Jul 25 '16 #1
4 865
twinnyfo
3,653 Expert Mod 2GB
Tyler1394,

Welcome to Bytes!

I don't think what you are trying to do sounds terribly difficult. There are a few things which are unclear, however.

First, if you are thinking of a "calculator" interface, then start there. Create a group of command buttons with number and operator labels on them. Then, as the user clicks on those command buttons, the calculation string would build. When the user clicks the "=" button, the string would be converted to the necessary numerical values (or these could be created along the way) and the result displayed.

One point of unclarity is how you want this result displayed. Would this simply save the date and an efficiency value (e.g. 25 Jul 2016 - 99.7%), or would it save an actual string (e.g. "25 Jul 2016 - 3 defects among 1,000 fabrics = 99.7% efficiency"), or several independent values (e.g. 25 Jul 2016; 3; 1,000)?

Additionally, what have you tried so far with this database? Typically, on this site, we assist users with modifying, correcting or improving existing work, rather than creating the result for them. This is all part of the collaborative learning process.

Hope this hepps!
Jul 25 '16 #2
Thanks for the welcome Twinnyfo!

I've attached an image showing what I was able to get to so far (although I realize now that i'm wrong).

From what I had essentially every click would simply update the textbox with the new info (click 9: textbox = 9, click 4: textbox = 4). With that I had no idea how to build up the textbox to say 94 or how I could get the VBA to save the number as a variable to then deal with an operation later (ex. 94 + X).

I believe part of that could be solved with the string operator you mentioned. I got my hands on a calculator template for access. For ever number command it has eg. #9 = handlecalc (9) where handlecalc(StrNum as String) or something like that. I suppose in this sense it would allow me to continually build the textbox up as a string. I would then need to save this is a separate variable when entering the operation and then the second input number.

I'm going to study that template for an idea of how to set up a functioning calculator, however this calculator simply does calculations without sending any information to the table. My issue would be translating/saving those inputs/results into a record of my choice (if they input 40 - move that to a record under the field of input or when they hit enter to save that value in a calculated field etc.)

With regards to your concern I would like to handle them separately so an administrator could view what all the inputs were if there were ever quality issues. In that sense (as mentioned above) I would like to be able to record almost any input (input01 saved to a record , operation, input02 saved to separate record, equals, result01 saved to third record) if that makes sense.

Attached Images
File Type: jpg Capture.JPG (19.4 KB, 175 views)
Jul 26 '16 #3
twinnyfo
3,653 Expert Mod 2GB
So, there are several ways to use these Command buttons. One is to have a procedure dedicated to each button, as you do. The other is to have one generic function that is called when the button is clicked (e.g., in the Command Button for the "5", in the OnClick Event, put "=ButtonClick(5)"). Then, this function ButtonClick() would figure out what to do with the value sent to it.

Very rough concept below:

Expand|Select|Wrap|Line Numbers
  1. Private Function ButtonClick(Value As String)
  2. On Error Goto EH
  3.     'Declare some variables that you might need
  4.  
  5.     'Determine if the value sent was a number or an operator
  6.  
  7.     'Either concatenate the number to a previous number
  8.     'or perform an operation
  9.  
  10.     'Finalize the values displayed on the form
  11.  
  12.     'If necessary, save the values to the table.
  13.  
  14.     Exit Function
  15. EH:
  16.     MsgBox "There was an error:" & vbCrLf & vbCrLf & _
  17.         Err.Number & " - " & Err.Description
  18.     Exit Function
  19. End Function
Again, this is a skeleton concept for the code, but this method will keep your code much cleaner, and is a good way to handle many controls with similar functions.
Jul 27 '16 #4
Thank you very much I appreciate it, i'll work on it and post back here with how it goes
Jul 27 '16 #5

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

Similar topics

3
by: _andrea.l | last post by:
how to build a interfaces (or web pages) in easy way? how to build a form in easy way? how to automate and create web pages whit a tool? which tool to use to create form for a database? I mean...
2
by: Michael Hertz | last post by:
Assume there is a XSD schema which describes the maximum possible number of fields which can occur in a XML document. How do I create such a form either as a HTML form or a text file from the XSD...
13
by: Geoff Cox | last post by:
Hello, How do I create a form without using document.write() which opens a new window? I imagine it has to do with using a <SPAN ID='idvalue' etc element and...
0
by: ghadley_00 | last post by:
MS Access Create form / report with multiple pages using different background images Hi, Would like to have users fill out a multipage form, and then click a print button, which pulls up the...
14
by: foxchan | last post by:
A Newbie question. Is it possible? Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oNewForm As Form1 'if already create a form...
3
by: ghat12 | last post by:
Hi, I have created a form containing 5 textfields/combo boxes and a command button to conduct searches for matching records. My results are currently displayed as a separate datasheet which is...
7
by: Roemer | last post by:
Hi all I stumbled over a new problem: I have a programm with just a class that is asynchronous listening for network connections. As soon as someone connected, a new form needs to be created....
0
by: Dan | last post by:
Hi, I deleted the form created by VWD in the aspx file (because i know there may only be one server-form) and I tried to create in the code-behind file a form like: dim t as form but it...
1
by: shapper | last post by:
Hello, I am creating a few forms for two web sites. The forms will have a header which I would like to style with CSS. My idea is to create the form as follows: <div id = "form"> <h1>My...
7
by: chrismaliszewski | last post by:
Hi. I created code which makes dynamically form with bounded controls for all columns. I show it to you below. My problem is, how I have to change this code to create form which record source...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.