473,769 Members | 6,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

question on coding a reset button

I am trying to figure out how to code a button labeled reset which will
clear the user input as well as clear out the two read-only text boxes. Here
is the program code that I have.

'declaring variables

Dim totalLiters As Double = Convert.ToDoubl e(txtLiters.Tex t)

Dim totalPints As Double = Convert.ToDoubl e(txtPints.Text )

Dim totalGallons As Double = Convert.ToDoubl e(txtGallons.Te xt)

'assigning text box values to variables

totalLiters = txtLiters.Text

totalPints = txtPints.Text

totalGallons = txtGallons.Text

'performing calculations

txtPints.Text = totalLiters * 2.1133

txtGallons.Text = totalLiters * 0.26
Feb 7 '06 #1
6 7933
Is it just me or are homework exercises getting simpler as time passes?

Whatever happened to a nice postfix expression evaluator?

Feb 7 '06 #2
What do you mean by that?

<al*******@user s.com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
Is it just me or are homework exercises getting simpler as time passes?

Whatever happened to a nice postfix expression evaluator?

Feb 7 '06 #3

I meant that this group is not really intended to provide a homework
service.
The question title was about a reset button and the first line of the
question re-iterates that but then the remaining sample code has
nothing whatsoever to do with it.

The repeated

Dim totalLiters As Double = Convert.ToDoubl e(txtLiters.Tex t)
...
totalLiters = txtLiters.Text

shows either a lack of care in formulating the question or a lack of
understanding of what the code does.
I am having a not fun day, I admit it, and you just happened to come up
(un)lucky.

But... it does behoove posters to have actually attempted to solve
their problem before posting (maybe have read a programming book,
searched through previous posts or even read the class notes). People
here are generally pretty generous with their time and if you are lucky
someone may handhold you through this. Or maybe not.
Alan.

Feb 7 '06 #4
It may or may not intrest you that I have absolutely no programming
experience at all, and I am having to learn VB from a book instead of in a
classroom environment where more time can be spent actually covering the
topics. The code I provided is what I wrote on my own and did not come from
anywhere else.
It also just so happens that I did look in a programming book. In fact, I
looked in at least three different books and I also looked through the index
file for the MSDN library. I came across the topic reset method and I looked
at that, but it did not seem that the example provided was the correct
procedure to use.
I'm sure that you could probably find a more efficient way to write the
code, but as long as the program works, what difference does it make?
Just because you may not be having a fun day doesn't mean that you can't
provide a meaningful reply. How else do you learn if you don't ask a
question?
<al*******@user s.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...

I meant that this group is not really intended to provide a homework
service.
The question title was about a reset button and the first line of the
question re-iterates that but then the remaining sample code has
nothing whatsoever to do with it.

The repeated

Dim totalLiters As Double = Convert.ToDoubl e(txtLiters.Tex t)
...
totalLiters = txtLiters.Text

shows either a lack of care in formulating the question or a lack of
understanding of what the code does.
I am having a not fun day, I admit it, and you just happened to come up
(un)lucky.

But... it does behoove posters to have actually attempted to solve
their problem before posting (maybe have read a programming book,
searched through previous posts or even read the class notes). People
here are generally pretty generous with their time and if you are lucky
someone may handhold you through this. Or maybe not.
Alan.

Feb 7 '06 #5
Charlie Brookhart wrote:
I am trying to figure out how to code a button labeled reset which
will clear the user input as well as clear out the two read-only text
boxes.


The way you'd (well, I would, anyway) do that is to have a separate section
of your program which initiliases everything, for example:

Sub init()
txtLiters.Text= ""
txtPints.Text=" "
txtGallons.Text =""
End Sub

So that in the code for your reset button (called ResetButton in this
example) you'd use:

Sub ResetButton_Cli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles ResetButton.Cli ck
init()
End Sub

(watch for line-wrap)

That way, if you need to clear the text boxes for any other reason, you can
simply call init().
I suspect you're rushing through your book a bit quickly, or perhaps it is
aimed at people who already have some programming experience. Maybe some
tutorials which start a bit sooner in the learning process would help you,
for example http://www.vbip.com/books/1861007612...er_7612_01.asp looks
ok at a quick glance. It's quite important to know a little about the
fundamentals of how computers work too:
http://computer.howstuffworks.com/microprocessor.htm (use a popup blocker to
preserve your sanity) might be of use to you.

HTH

Andrew
Feb 8 '06 #6
There is just one programming class which happens to be part of the overall
degree program that I am enrolled in. I think that this class could very
well be aimed towards those that have prior programming experience. Any
additional resources that I can find would be helpful in this learning
process.
"Andrew Morton" <ak*@in-press.co.uk.inv alid> wrote in message
news:ed******** ******@tk2msftn gp13.phx.gbl...
Charlie Brookhart wrote:
I am trying to figure out how to code a button labeled reset which
will clear the user input as well as clear out the two read-only text
boxes.
The way you'd (well, I would, anyway) do that is to have a separate

section of your program which initiliases everything, for example:

Sub init()
txtLiters.Text= ""
txtPints.Text=" "
txtGallons.Text =""
End Sub

So that in the code for your reset button (called ResetButton in this
example) you'd use:

Sub ResetButton_Cli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles ResetButton.Cli ck
init()
End Sub

(watch for line-wrap)

That way, if you need to clear the text boxes for any other reason, you can simply call init().
I suspect you're rushing through your book a bit quickly, or perhaps it is
aimed at people who already have some programming experience. Maybe some
tutorials which start a bit sooner in the learning process would help you,
for example http://www.vbip.com/books/1861007612...er_7612_01.asp looks
ok at a quick glance. It's quite important to know a little about the
fundamentals of how computers work too:
http://computer.howstuffworks.com/microprocessor.htm (use a popup blocker to preserve your sanity) might be of use to you.

HTH

Andrew

Feb 8 '06 #7

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

Similar topics

5
3108
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the user clicks on the "Choose" button of the input field (to select a file on the local disk), then radio button B is automatically
4
10991
by: Chris Lane | last post by:
Hi, I have an HTML RESET button and Web Control Button that posts back to the server. Problem is the reset button doesn't work after the postback occurs. Any ideas or suggestions as to why this happens or how I can work around this? Thanks
3
1232
by: Harry | last post by:
Dear all, It is found that when a webform control trigger an event, Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub This function will be load first, followed by
4
5331
by: Lee Chapman | last post by:
Hi, Can anyone tell me why in the code below, the call to ClearChildViewState() has no effect? To paraphrase the code: I'm using view state. I have a textbox and a submit button (and a label that can be ignored). When I press the button the first time, the click handler hides the textbox. Pressing the button a second time unhides the textbox. The text box is maintaining its value when hidden via view state. (The value is NOT being...
3
1590
by: Debbie Carter | last post by:
Can XML files be easily encrypted?
2
5226
by: Roger Withnell | last post by:
I need to reset a form to its original value using onclick rather than the Reset button. So, I have: <input type="button" name="reset" id="reset" value="Reset" onclick="form1.reset();"> where the id of my form is "form1". This gives the error "Object doesn't support this property or method". Please advise.
5
1406
by: theflyingminstrel | last post by:
Hi I have a question, it's probably very basic but I'm still learning the Javascript basics. The following form outputs a string change (from "input" to "text" box ). When the word "test" is inputted, it changes to "good". Simple question: If there is no matching string, how would I get the form to just display nothing at all? Thanks! <html>
3
2175
by: Zubulake | last post by:
I am having problems with my homework. I am making a code for a alarm clock and i need to disable the set button and the dateTimepicker and transfer focus to the reset button. Then when i hit the reset button i need to transfer focus back to set button This is what i got for the set button If DateTimePicker.Text = True Then setTimeButton.Enabled = False resetButton.Focus() End If
2
7667
by: Ken Fine | last post by:
I want to add the security question and answer security feature to the ChangePassword control. I am aware that this functionality is built into the PasswordRecovery tool. I have implemented the PasswordRecovery with a Password reset required; a temporary password is sent to the account on file. I want an extra layer of security to accommodate the very unlikely contingency that someone's e-mail account is compromised. Challenging with the...
0
9587
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
10045
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
9993
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
8870
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
6672
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
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
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.