473,385 Members | 1,720 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.

Problems with boolean

Hi all! I've just started playing around with Visual
Basic 6.0 and tried to make a calculator just for fun.
Everything works except for the decimal button which has
some serious issues!! Everytime I click the button it
will display a decimal point on the screen which is
obviously not what I want.
I used the following declaration at the beginning of the
code
Private decimalclick as Boolean

and then the procedure for the decimal button click is as
follows

Private Sub decpt_Click()

If decimalclick = False Then
display.Caption = display.Caption + "."
decimalclick = True
End If

End Sub

The logic to me is sound, but it is evident that the
decimalclick value continues to stay False, please help
me out.
Thanks alot
Nov 20 '05 #1
2 993
* "Mehul Malhotra" <me************@yahoo.com> scripsit:
Hi all! I've just started playing around with Visual
Basic 6.0 and tried to make a calculator just for fun.
Everything works except for the decimal button which has
some serious issues!! Everytime I click the button it
will display a decimal point on the screen which is
obviously not what I want.
I used the following declaration at the beginning of the
code
Private decimalclick as Boolean

and then the procedure for the decimal button click is as
follows

Private Sub decpt_Click()

If decimalclick = False Then
display.Caption = display.Caption + "."
decimalclick = True
End If


Your code should work. Nevertheless, I would use '&' to concatenate
strings and write 'If Not DecimalClick Then...'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
"Mehul Malhotra" <me************@yahoo.com> wrote in message
news:5f****************************@phx.gbl...
.. . .
Everything works except for the decimal button


So; you don't want a[nother] decimal to appear if you already have
one in the display - how about this?:

Private Sub decpt_Click()
If Instr( display.Caption, "." ) = 0 Then
display.Caption = display.Caption & "."
Else
Beep ' ;-)
End If
End Sub

HTH,
Phill W.
Nov 20 '05 #3

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

Similar topics

1
by: AA | last post by:
I want to Deserialize this simple xml... ==================================================================== <SubmitReq...
2
by: longtim | last post by:
I have been trying to implement navigation buttons for a number of forms in my application. Creating the 'Next' 'Previous' buttons has been fine but setting the enabled properties doesn't work...
0
by: stephan | last post by:
I know that this has been beaten to death but I can't seem to resolve my issues (I have 2 of them). I have created a class that exposes a public method which returns a datatable as a datasource...
5
by: Roy Gourgi | last post by:
Hi, I just installed VS 2005 Express with SQL Server and when I try to run the code that was working with VS 2003 is no longer working. Is it not backward compatible. What has changed. Below is...
2
by: Joel D. Kraft | last post by:
I've been very happy with the performance and new features of my site since we converted to ASP.NET 2.0 beta 2. I have noticed a couple of interesting problems, though, which I am trying to...
3
by: Jon Turner | last post by:
I have an asynchronous call to a remote procedure that is invoked thru BeginInvoke. The problem is that in the Delegate if I throw an event before the CallBack function exits, the CallBack will...
1
by: nate axtell | last post by:
In VB .Net I made a custom CheckBox column style (for the Datagrid control) that maps to two DataTable columns , one it uses for the Checked status and the other it uses for the Enabled status. I am...
36
by: Chuck Faranda | last post by:
I'm trying to debug my first C program (firmware for PIC MCU). The problem is getting serial data back from my device. My get commands have to be sent twice for the PIC to respond properly with...
0
by: neoret | last post by:
Hello. I have developed an application (an office addin).The application works fine with no error messages on my devoping machine (that machine is not connected to any domains). I have...
0
by: neoret | last post by:
Hello. I have developed an application (an office com addin).The application works fine with no error messages on my devoping machine (that machine is not connected to any domains). I have...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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
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...

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.