473,396 Members | 1,924 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.

subtracting

This is the code ive got for a subtract button

mdcurrentresult -= txtresult.Tex
txtresult.Text = mdcurrentresult.ToString(
mbOperationbuttonPressed = Tru

Now this almost works it subtracts and gets the right answer apart from the fact that it turns everything into a negative number except numbers which are meant to be minus which it turns into positives.
for exampl
6-4= -2 should equal
4-6= 2 should equal -
What can I do to the code to make it work properly
Also how do I use keypress and where do I put in the code for it and how do I make it work

thanx everyone
Nov 20 '05 #1
16 1939
Cor
Hi Tom,

I do not see it directly however this is not real good code.
As you have maybe seen often in this newsgroup is here late binding used,
and that makes it a little bite unpredictable.

If you set Option String on above your class you will get an error on this.

mdcurrentresult = mdcurrentresult - Cint(txtresult.Text) 'assuming you where
using integer
txtresult.Text = mdcurrentresult.ToString()
mbOperationbuttonPressed = True

When you use VS.net and you click on the button in your designer it will for
you create a click event. Not the nicest however for this usable the
keypress you get to select in your code the button in the dropdownbox left
above and then the keypress event in the rigth dropdownbox on the same line.

I hope this helps?

Cor

Nov 20 '05 #2
Cor
Hi Tom,

I do not see it directly however this is not real good code.
As you have maybe seen often in this newsgroup is here late binding used,
and that makes it a little bite unpredictable.

If you set Option String on above your class you will get an error on this.

mdcurrentresult = mdcurrentresult - Cint(txtresult.Text) 'assuming you where
using integer
txtresult.Text = mdcurrentresult.ToString()
mbOperationbuttonPressed = True

When you use VS.net and you click on the button in your designer it will for
you create a click event. Not the nicest however for this usable the
keypress you get to select in your code the button in the dropdownbox left
above and then the keypress event in the rigth dropdownbox on the same line.

I hope this helps?

Cor

Nov 20 '05 #3
"Cor" <no*@non.com> schrieb
If you set Option String on above your class you will get an error on
this.


Your wife might have Option String On, but not VB.NET

;-)))
--
Armin

Nov 20 '05 #4
"Cor" <no*@non.com> schrieb
If you set Option String on above your class you will get an error on
this.


Your wife might have Option String On, but not VB.NET

;-)))
--
Armin

Nov 20 '05 #5
Cor
LOL
Your wife might have Option String On, but not VB.NET

;-)))

Nov 20 '05 #6
Cor
LOL
Your wife might have Option String On, but not VB.NET

;-)))

Nov 20 '05 #7
do a bit flip on the signed integer.. that will reverse the sign... make a
mask for the size in bytes of the integer, flip the highest order bit, that
reserses the sign of the value.

"Tom W" <an*******@discussions.microsoft.com> wrote in message
news:B0**********************************@microsof t.com...
This is the code ive got for a subtract button.

mdcurrentresult -= txtresult.Text
txtresult.Text = mdcurrentresult.ToString()
mbOperationbuttonPressed = True

Now this almost works it subtracts and gets the right answer apart from the fact that it turns everything into a negative number except numbers
which are meant to be minus which it turns into positives. for example
6-4= -2 should equal 2
4-6= 2 should equal -2
What can I do to the code to make it work properly?
Also how do I use keypress and where do I put in the code for it and how do I make it work?
thanx everyone

Nov 20 '05 #8
do a bit flip on the signed integer.. that will reverse the sign... make a
mask for the size in bytes of the integer, flip the highest order bit, that
reserses the sign of the value.

"Tom W" <an*******@discussions.microsoft.com> wrote in message
news:B0**********************************@microsof t.com...
This is the code ive got for a subtract button.

mdcurrentresult -= txtresult.Text
txtresult.Text = mdcurrentresult.ToString()
mbOperationbuttonPressed = True

Now this almost works it subtracts and gets the right answer apart from the fact that it turns everything into a negative number except numbers
which are meant to be minus which it turns into positives. for example
6-4= -2 should equal 2
4-6= 2 should equal -2
What can I do to the code to make it work properly?
Also how do I use keypress and where do I put in the code for it and how do I make it work?
thanx everyone

Nov 20 '05 #9
Ok I changed the code t
\\\\\mdcurrentresult = mdcurrentresult - Cint(txtresult.Text) 'assuming you wher
using intege
txtresult.Text = mdcurrentresult.ToString(
mbOperationbuttonPressed = Tru
/////
but it still turns everying into a negative. Which part is the integer? sorry I'm new
good joke to LO
thanx
Nov 20 '05 #10
Ok I changed the code t
\\\\\mdcurrentresult = mdcurrentresult - Cint(txtresult.Text) 'assuming you wher
using intege
txtresult.Text = mdcurrentresult.ToString(
mbOperationbuttonPressed = Tru
/////
but it still turns everying into a negative. Which part is the integer? sorry I'm new
good joke to LO
thanx
Nov 20 '05 #11
Hi Tom,

This code I did try, so there should be something else?

Cor

Dim mdcurrentresult As Integer
Private Sub Buttonminus_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) Handles
ButtonMinus.Click
If IsNumeric(TextBox1.Text) Then
mdcurrentresult = mdcurrentresult - CInt(TextBox1.Text)
TextBox1.Text = mdcurrentresult.ToString()
End If
End Sub
Private Sub ButtonPlus_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) Handles
ButtonPlus.Click
If IsNumeric(TextBox1.Text) Then
mdcurrentresult = mdcurrentresult + CInt(TextBox1.Text)
TextBox1.Text = mdcurrentresult.ToString()
End If
End Sub
Nov 20 '05 #12
Hi Tom,

This code I did try, so there should be something else?

Cor

Dim mdcurrentresult As Integer
Private Sub Buttonminus_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) Handles
ButtonMinus.Click
If IsNumeric(TextBox1.Text) Then
mdcurrentresult = mdcurrentresult - CInt(TextBox1.Text)
TextBox1.Text = mdcurrentresult.ToString()
End If
End Sub
Private Sub ButtonPlus_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) Handles
ButtonPlus.Click
If IsNumeric(TextBox1.Text) Then
mdcurrentresult = mdcurrentresult + CInt(TextBox1.Text)
TextBox1.Text = mdcurrentresult.ToString()
End If
End Sub
Nov 20 '05 #13
Ok I think I might have found the problem here since it still turns into a negative
This is the code for the equals button
\\\\\\ Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnequals.Clic
mdcurrentresult += txtresult.Tex
txtresult.Text = mdcurrentresul
mbOperationbuttonPressed = Tru
mdcurrentresult =
End Su
/////
I think its the plus sign mucking it up ( after mdcurrentresult ) I tried taking it out and nothing happened (the plus and minus buttons did nothing) then i tried putting the minus sign in instead but then the minus button did adition and (but added a negative sign) and the plus button did perfect subtractions. I thought about making another eqauls button so the plus button worked but having 2 equals buttons was a bit silly.
Can someone tell me if the code for the equals button is right
thanx
Nov 20 '05 #14
Ok I think I might have found the problem here since it still turns into a negative
This is the code for the equals button
\\\\\\ Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnequals.Clic
mdcurrentresult += txtresult.Tex
txtresult.Text = mdcurrentresul
mbOperationbuttonPressed = Tru
mdcurrentresult =
End Su
/////
I think its the plus sign mucking it up ( after mdcurrentresult ) I tried taking it out and nothing happened (the plus and minus buttons did nothing) then i tried putting the minus sign in instead but then the minus button did adition and (but added a negative sign) and the plus button did perfect subtractions. I thought about making another eqauls button so the plus button worked but having 2 equals buttons was a bit silly.
Can someone tell me if the code for the equals button is right
thanx
Nov 20 '05 #15
Hi Tom,

Why do you not use that txtResult.Text box to keep your results.

txtResult.Text = (Cint(txtresult.Text) and the needed operand and Cint(your
other textbox.)).toString

This looks much clearer (when the text is gone) than creating extra value
storages.

My sample works also (Do not forget that Isnumeric)

I hope this helps

Cor
Nov 20 '05 #16
Hi Tom,

Why do you not use that txtResult.Text box to keep your results.

txtResult.Text = (Cint(txtresult.Text) and the needed operand and Cint(your
other textbox.)).toString

This looks much clearer (when the text is gone) than creating extra value
storages.

My sample works also (Do not forget that Isnumeric)

I hope this helps

Cor
Nov 20 '05 #17

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

Similar topics

8
by: simpleman | last post by:
Hi, I have an assignment that requires me to subtract two very large unsigned integers using linked list.AFAIK I have to manipulate data as character. But I dont know how to get input into the...
7
by: Old Wolf | last post by:
For the following code: int main(void) { short a, *ptr; ptr = a + 100; ptr -= 0; }
11
by: Laery | last post by:
Hi, I'm currently adding a new module to an old borland C3.1 application (dos). And I need to calculate a date by subtracting the number of days from a given date. I know I could use an...
8
by: Ifollowhim | last post by:
I have a (installation) date in a table that I put in manually. It is the date we want to complete a job. In a form that uses data from that table I want to add a text box that is bound to the...
31
by: Spiro Trikaliotis | last post by:
Hello, I have a question regarding subtracting a pointer from another one. Assume I have two pointers p1 and p2, which both point to a memory area obtained with malloc(). Assume p1 = p2 + some...
3
by: Martin Joergensen | last post by:
Hi, Just a small problem (about taken the previous unsigned value in a 1D- array and copying it to the current value). Suppose there's an outer loop over the line shown below, so...
2
by: Paulers | last post by:
hello all, how does one go about subtracting seconds from a DateTime object? for example I have a date time of "06/04/2007 10:31" and I need to subtract 12 seconds from that. all help is...
2
by: parkc | last post by:
I want to return the difference number of records. Here are the queries: --subtracting columns with columns and descriptions (columns - columns and descriptions) --difference of 30 records...
3
by: nicekul | last post by:
I am having problems subtracting from unitsInStock for all records on my table, for instance; I have Quantity sold, Unit Price,UnitsInStock,Total sales, Stock Balance. I declared Dim num1 Dim...
14
by: Krumble Bunk | last post by:
Hi all, I have an elementary question, of which I never grasped, and i'd like to finally put it to rest. I have the following code, which although makes use of the string library, and could...
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: 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...
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.