Hi guys
Im new to visual basic, and I am 14 yrs old, so I beg you to bear with me.
I want to make a simple program that tells you whether the input is a positive number or a negative number. I have tried everything i know, but to no avail.
Please help me
Thanks
5 35947
Good afternoon, if the number you are trying to determine is negative or positive is in a text box control then you have to turn it into a long or and integer. (will not work normally as it is determined as a string). So instead of using -
If Text1.Text < 0 Then
-
MsgBox "Negative"
-
ElseIf Text1.Text > 0 Then
-
MsgBox "Positive"
-
Else
-
MsgBox "Is not a number or is 0"
-
End If
-
you have to turn them into Longs or Integers with either Clng or Cint for example -
If CInt(Text1.Text) < 0 Then
-
MsgBox "Negative"
-
ElseIf CInt(Text1.Text) > 0 Then
-
MsgBox "Positive"
-
Else
-
MsgBox "is not a number or is 0"
-
End If
-
The above code is tried and tested my friend. (ps. you can change it from an Integer to A Long by changing: -
If CInt(Text1.Text ) < 0 Then
to
If CLng(Text1.Text ) < 0 Then
Hope this helps you
Kind regards
Devon.
Hi. so this will be part of an assignment. Is it the entire assignment or just a part of it?
Hi guys
Im new to visual basic, and I am 14 yrs old, so I beg you to bear with me.
I want to make a simple program that tells you whether the input is a positive number or a negative number. I have tried everything i know, but to no avail.
Please help me
Thanks
So if you are reading in from txtBox1 -
-
value=ToDouble(txtBox1.Text) 'convert an input into numerical form
-
-
IF value > 0 'check to see if it is greater than 0
-
msgbox "Value Entered is positive"
-
-
ELSE
-
msgbox "value Entered is negative" 'If it isn't then...
-
-
Thanks for your reply! I really appreciate your help.
No, this is not part of an assignment, I am trying to make a program that helps you to sketch a parabola by finding concavity, vertex, etc. to help my friends.
I am so stupid! I tried all wierd things like diving by -a, -1 and all random stuff. Thankyou sincererely!
...I am so stupid! I tried all wierd things like diving by -a, -1 and all random stuff. Thankyou sincererely!
Jumping around trying out lots of ideas can be a good way to not only solve a problem, but learn stuff along the way. But you do need to keep in mind some idea of where you're going, or you could be thrashing around forever.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: KathyB |
last post by:
Hi,
I just can't get this quite right. I use the following function to
validate a user entry. I need to allow negative numbers including
those with decimals (e.g., -.5). The following allows the decimals but
not the negative. Any help appreciated...as always. Thanks -- Kathy
function ValidateSave(formRef,fieldName,min,max) {
var formField = formRef.elements;
if (!/^\d+(\.\d+)?$/.test(formField.value)) {
|
by: Dig314 |
last post by:
I need to Total the amounts for each Property ID in a table.
All the amounts are stored as positive in the database.
Based on a transaction code, the amount should be added or subtracted.
There are about 14 transaction codes, but here is an example:
Transaction Code "Addition" - - add the amount
Transaction Code "Disposal" - - subtract the amount
Can this be done in single select statement ?
|
by: hasanainf |
last post by:
Hi all,
I have two querys
QueryPurchased
ProductID Location TotPcs
Prod1 Loc1 100
Prod2 Loc1 50
Prod3 Loc1 150
Prod3 Loc3 150
|
by: Johs |
last post by:
I need to make some special action if 'a' and 'b' are both positive or
both negative. Is there some inbuilt function to check this?
Johs
|
by: AccessIdiot |
last post by:
I'm sure this must be possible but I'm still a newbie and not sure how to do it.
Part One:
Using the good 'ol customers and orders tables and forms example - how would I go about putting a little text box on the customers form that shows, for any given record (customer), the number of related orders that customer has?
In pseudocode its something like count the number of records in Orders where Customer_ID = X.
Would the code go in the...
| |
by: STEPHENSS |
last post by:
Hi,
New to SQL.
I need to reverse the signs, for example I have an amount of -1,500.00 and I need to change the the Amount to 1,500.00 and all positives amount to a negative amount also.
Thank you
Stephen
|
by: vbgunz |
last post by:
/*
* BEGIN EXAMPLES
*/
var text = 'A Cats Catalog of Cat Catastrophes and Calamities';
/***
* EXAMPLE 1: negative lookahead assertion logic
***/
|
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...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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,...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |