Add 2 Numbers
after i enter a number into the textbox, i want it to be store in a temporary variable when i click a button, after that, the textbox will be assign to null and then i enter another number and after i press the button again, i want these 2 numbers to be added.
How can i do that?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
[SOLVED]FormatCurrency Returns Numbers As Text Instead Of Formatted Numbers
This seems as a really dumb question but..... why is it that numbers resulting from a calculation work perfectly BEFORE I format them as currency and DO NOT work as numbers after I have formatted them?
Code:frmDCashFlow.Text7.Text = Val(frmDCashFlow.Text4.Text) + Val(frmDCashFlow.Text5.Text) + Val(frmDCashFlow.Text6.Text) 'This returns a value... OK
frmDCashFlow.Text7.Text = FormatCurrency(frmDCashFlow.Text7.Text, 0) ' This returns numbers as text, that can't be used to calculate once formatted....
Why and how can I avoid this? The FormatCurrency function is supposed to return a numeric expression formatted as currency value.....
Thanks for any help
_________________________________________________________________
Edited by  vbprog1144 on 10/26/2004 1:00:34 PM
Converting String Numbers Into Real Numbers
Hi,
I have a formula in VBA that searches through a table for corresponding results to the conditions I specified and sort the results into another table. My problem is that the data I use, which includes monetary values, seems to have converted them into string numbers (which include de $ sign as part of the characters and not only into a simple visual effect). It's a problem when I want to do mathematic operations with those monetary values. Is there a way to convert them into real numbers in my VBA code just before doing my maths with them? I tried to preformat the cells before their extraction but it seems it isnt enough to really convert them.
Thx!
Werner
Splitting Large Numbers Into Smaller Numbers
i want to divide a decimal into smaller decimals in an array form.
e.g.
starting with 0.22335566
array(0) = 0.22
array(1) = 0.0033 or 3.3 *102
array(2) = 0.000055 or 5.5*104
etc.
can anyone help?
thanx a million
How Do You Convert Whole Numbers To Decimal Point Numbers?
I have this code and it adds 9+9 then divides by 4 which = 4.5 and places it in a text box, but it dosn't show the 5 after the point.
Code:a = 9: b = 9
text(8).text = a+b
text(8).text = text(8).text 4
text(8).text = Format(text(8).text, "#.##")
Whats wrong here?
Thanks,
Bob K
Edited by  Bob K on 3/17/2005 7:17:06 PM
Sorting Texts And Numbers As If It Was All Numbers
Hi,
I have a list of appartement numbers. Sometimes it's written 102 or sometimes 102a and 102b.
E.G
102
103
104a
104b
105
(...)
Actually, if I record a macro to sort those valuesm it puts 104a and 104b at the end of the list, without considering them as numbers which are locally before 105. Note that it could be one, two, three or more digits. It would be a dynamic lenght. The letter too could be dynamic as well.
Is there a way to tell Excel/VBE to sort intelligently this list?
Thx!
Werner
Code:
Sub Sorting()
Rows("16:29").Select
Selection.Sort Key1:=Range("A16"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub
Random Numberssame Numbers/different Order
HI, I'd like to display 4 numbers randomly. I would like the same 4 numbers to be displayed each time the random code runs but in a different order each time.
I'v etried the ran() function but it doesn't quite do the job.
Any ideas?
Compare Numbers And Save Numbers
Hi pros,
set 1 52
set 2= 1325
Now i make a compare these two set of numbers.
if mid(set1,Acounter,1)<>mid(set2,Bcounter,1)then
set 1 first no.1 match with set 2 no.1 =right number
IF set 1 no.2 match with set 2 no.2 but at third position once it match will end the loop. How can i save the set 2 no.5 in fourth position?
Thank you.
Yahoo! Biztools
 Promote your business from just $5 a month!
Enter Numbers From A Set Of Numbers, But Only Allow It To Be Entered Once.
Hi all,
I am trying to make an app for work, what I want to do is
1. Create a list of numbers, no real order and they will be added to and removed from as well
2. I then want to add them in a form (similar to an excel spreadsheet) with text boxes as I need them and I should only be able to add them once, ie.. no duplicate numbers
I hope this is not too vague. Thanks
Regards
David
Generating Random Numbers, Whole Numbers Only
hello all!
I used this code to generate random numbers in VB:
Code:lRndNum = (65000 * Rnd)
where I wanted to produce a bunch of random numbers from 0 to 65000.
My problem is, I want to discard the decimal points in the generated random result.
I only want to have random numbers, whole numbers, that is, without the messy decimal point.
I hope you'll hear me out. Thanks!
Random Numbersis It Possible To Generate Random Numbers With A Algorithum?
The rnd function in vb generated pseudorandom numbers. That means if you use these numbers as a key for some type of encryption it would make it fairly easy to break(if you knwo how) because you can predict what numbers will be generated by the rnd function.
I'm trying to design a method that might involve a couple of diffrent algorithums to genertae random numbers.
One of my idea's was to monitor network traffic for numbers, error messages, etc...
If anybody has idea's, code, or comments please reply!
At the moment I have absolutely know idea howto monitor the arrival of packets or error messages, so if you knwo how please respond!!!
Numbers....
Hi,
I'm doing a game on numbers, and whenever i enter the following code:
(rNumber(1) + rNumber(2)) > (rNumber(3) + rNumber(4))
, the program works out fine and runs smoothly. The problem is that I have to create many different numbers and the whole program gets sluggish and the code gets extremely confusing and messy. But when I enter the code and do this:
MyTotal = rNumber(1) + rNumber(2)
ComTotal = rNumber(3) + rNumber(4)
'Substitute (rNumber(1) + rNumber(2)) with MyTotal
'Substitute (rNumber(3) + rNumber(4)) with ComTotal
MyTotal > ComTotal
, the program runs smoothly but the mathematical operation stops functioning! I would appreciate any help...
Thanx
Add All The Numbers Up That Are Within A RTB
I have a richtextbox which is populated with numbers which are seperated by VbCrLf. I believe it is important to note, however, that at times the RTB may contain just one line with no VbCrLf. I need to ADD all of the numbers together and produce a total sum of all the numbers contained in the RTB. I think I need to SPLIT() the text in the RTB at each VbCrLf and then add that moment's number to the total thus far produced. My code below does not work. Might somebody kindly explain why this is so. Thank you in advance!
Quote:
Dim TextboxText As String
Dim NumericValue As Integer
Dim Tally As Integer
TextboxText = RTBValues.Text
NumericValue = Split(TextboxText, vbCrLf)
For X = 0 To UBound(NumericValue)
Tally = Val(Tally) + Val(NumericValue)
Next X
To further clarify. I get an error "EXPECTED ARRAY" and VB highlights UBound in the For Loop. Furthermore, if I delete the entire For Loop I get a different error. Without the For Loop in the code, I get the error message "RunTime Error : Type Mismatch" and the entire line where I define the NumericValue variable is highlighted.
Help...
Mop Numbers
I'm having a trouble solving this problem:
A mop expression is a way of producing a number using only multiplications, ones and pluses. The length of a mop is the number of ones it contains.
For example, 22 = 1+1+((1+1+1+1)x(1+1+1+1+1)), which has a length of 11.
Another mop of 22 is 1+((1+1+1)x(1+((1+1)x(1+1+1)))) which has a length of 10. There are no shorter mops for 22.
<b><u>i have to write a function that inputs an integer and returns the shortest mop...</b><u>
iv been told:
"Any “mop” should satisfy n=C+(XxY)
where C,X,Y are recursive “mop”s
the sum of the resulting “mop” values C+X+Y is the length.
Prime case P: initial C must be >0
(XxY)= lower number “mop”
Factorable case: initial C can be 0
Find factors “mop”s {X,Y}>=2
Take the factors distribute them between X and Y
For every distribution find the lowest length “mop”s"
but I dont understand this or how I can use it in practice (VB6)!!!
any help will be appreciated!
Odd Numbers
i was just wondering how i would go about calculating only odd numbers
eg.
input 1 and display the next 39 odd numbers.....
Max Numbers And Min Numbers
Need help on this one
i have like 9 numbers in a list box and i want to find the highest number in the listbox and the lowest number in the list box how exactly do i do that? does it have anything to do with Lower Bound and Upper Bound? So far this is my code, it displays 10 numbers in a list box these numbers are between 1 and 99 all i need now is so that once the Miniumum command button is clicked or the Maximum command button is clicked the label1 box will show the number greatest/lowest
Private Sub Form_Load()
Randomize
For intNum = 0 To 9
List1.AddItem RndInt
Next[/i]
End Sub
Function RndInt()
RndInt = Int(Rnd * 99) + 1
End Function
Min And Max Numbers
Hi,
I'm running a VB program and adding data using arrays. after entering the data I have managed to find the total of all numbers and the average using the example code below:
Private Sub cmdDisplay_Click()
Dim myTotal As Single, myAverage As Single
If myOption = 0 Then ' Sum of temperatures
For Y = 1 To X
myTotal = myTotal + myTemp(Y)
Next
MsgBox myTotal
ElseIf myOption = 1 Then ' Average temperature
For Y = 1 To X
myTotal = myTotal + myTemp(Y)
Next
myAverage = myTotal X
MsgBox myAverage
End If
End Sub
I am now trying to find a way of obtaining the highest and the lowest number from the range of numbers entered 'myTemp(x)'.
Can anyone help?
Thanks,
Matt.
Key Numbers
Select Case KeyAscii
Case vbKey0 To vbKey9
Case Else
KeyAscii = 0 'throw away 09
End Select
i can type 19 right?
but i cant type
45.55 because it has a . in it
and i cant use backspace...
is there somewhere with the layout of all the key numbers?
I Could Use Some Help In VB6.0 {odd Vs Even Numbers}
yeah....recently i was assigned a program to finish from Using Visual Basic chapter 6, called the Goldbach Conjecture if anyone is familiar with it. How does one go about telling the program what to do if the input number is even or odd.
Confusing wording?
let me try again...
i need to tell the program what to do depening on if the number is even or odd, i dont know the code to alert the program for an even or odd number.
Numbers Only
i have a text box and only want 0123456789/. as valid input
i saw a post on here before but can't find it at all now
any ideas how to do this?
Need Help With Numbers
I have a program that reads the last record number from an ini file, then add a new record with the next number. My problem is if the number is less than 10, I need it to add a 0 in front of the number. In other words, I need 08, 09, 10. Right now I get 8, 9, 10. Can someone give me an idea how to do this.
Help With Numbers...
Ok, I want to know how to be able to take a 16 digit number and letter combination and divide them into 2 sets, the first 8 numbers, and then the second 8 numbers. I just want to turn them into strings and then do what I want with them. Any help?
Anyone Knows Anything About Numbers And Such?
I was wondering how to enable only numbers to be inputted under the input box...So when the user types in alphabets or leave's the input box blank a message box will prompt asking them to only insert numbers
Numbers
Hello, I was wondering if anyone knows how to place an array of numbers into order  smallest to largest
So if I had
X(1) = 5
X(2) = 9
X(3) = 2
X(4) = 3
X(5) = 8
How could I order it like this:
Y(1) = 3
Y(2) = 4
Y(3) = 1
Y(4) = 5
Y(5) = 2
So the y array equals the x array in order. Aaarrg! I dont know how to word it. Does anyone know what I mean? Oh well.
Thanks if you get it.
Numbers
I have bean try to figure this one out for awhile now.
say i have 33 numbers and need to do something to every group of ten numbers but only groups of ten numbers how would i do this.
+ve, ve Rnd Numbers
Does anyone have any idea how i can generate a positive or negative number randomly.
Ive experimented with trying to generate 2 random numbers, the first would be the number, eg 56
and the second number, generated between 1 and 99, would decide whether it would be positive or negative, my initial idea was that if the second number generated was even then the first number would be made positive, and if the second number was odd then it would be negative.
Problem is i cant work out how to check for a even or odd number.
any ideas or help would be appreciated.
Thanx
Scytheuk
Add Numbers
can anybody help me with a code to add or take away "0" to the left of my binary conversion depending on a chkbox?
private sub cmdToBinary_click()
call restrict
End sub
Public sub restrict()
If chkbox.value=vbchecked and Len(txtBinary.text) <8 then
'add zeros to the left (Len(txtBinary.text) = 8)
Else if chkbox.value=vbunchecked and Len(txtBinary.text) = 8
'take away zeros from left of binary no's until first 1
End If
End sub
"Shibby!"
Odd/Even Numbers
I was wondering if i could use an if statement saying if variable = an even number Then
do whatever
How would i do that? (and another one for odd numbers)
Thanks in advance.
Only Numbers ?
How can i programm a text field that there can only entered numbers, so 0 , 1 , 2 , 433434, 54545.45 etc.etc
text1_change
Code:
if text1.text = ??? Then
else
msgbox("Onley numbers")
endif
Can you help me ?
Numbers Between 1 And 9
I want to get users to enter a number but when they enter numbers between 1 and 9 I want to store it as 01, 02, 03... 09etc. Is there any way of doing this apart from the tedious way of using if statements?
Numbers Only
Hi
I am creating a Cash register program.
I want the txtBox to accept numbers only.
If the user hits a letter it need to do nothing.
I have used the "isnumeric" to see if the txt entered is a number or not.
Private Sub txt0_Change(Index As Integer)
intButNum = Index
lbl0(Index).Caption = ""
If IsNumeric(txt0(Index).Text) = True Then
int0(Index) = txt0(Index).Text
Else
now what here??
Thanks in advance.
HELP: Need Help {with BTW Numbers}
Okay guys, this is my first post here because I need some help and I need it fast.
Heres the deal: I need to make this thingy and I have no idea how to start on it.
Thinking you guys are all masters at visual basic , I thought: Why not take my chance here.Anyways here goes:
The program needs to do this:
A btwnumber in belgium is formed as followed: BE XXX.XXX.XXX where BE represents the country(belgium in this case). In belgium you can check if the BTW number is correct by dividing the number formed by the first 7 letters(the ones in green) with 97(no comma numbers). then you gotta do 97 minus the rest of the deviding. the number you get now must be the same as the 2 last letters in the BTW number(ones in red).
If this is correct a label will change with the message showing: "this is correct"
else it must be : " This isn't correct "
This is my big trouble, considering myself as a big visual basic noob I would appreciate all help or a link to where I can find answers to this stupid exercise.
Thanks alot. (btw im from belgium so if my english is a bit bad at some points exuse me for that )
EDIT: this is what the layout of the program must look like http://users.pandora.be/cs_er/Pic.JPG
Numbers?
hey. i want a program so that someone enters a number (say 5) and it will do this.
5x4x3x2x1 and tell u the answer.
so like if i enter 8 it will telll you the answer to 8x7x6x5x4x3x2x1
i dont get how i would do it :S
Big Numbers
Hi ! I'm having troubles working with big numbers: I'm working with some numerical methods to make a lot of calculations, but I've tried with all data types (single, double) to find some overflow problems. What can I do ? Should I use other diferent type ? I tried too with Currency, but then I have problems with little numbers.
Thanks a lot
Very Very Big Numbers
Anybody know a relatively simple way of working with very big numbers? I mean really big, far and beyond a double's max value. I could write up a function to use a string variable to store the value and break the math down into simpler calculations, but that would add a lot of coding and slow the program down substantially, especially since I need to do the calculations many times. Any Ideas?
Help! Numbers Just Won't Add Up?
Hiya everyone.
I've searched through the forums and still can't find an answer to my 'probably' very simple problem. I've only been learning VB for a few months so I'm still a newbie. I've written the code for my program (another one of those basic calculator programs that we've all done at some point!) I've declared all my variables, my cmdExit and cmdClear buttons works fine, the operations multiply (*), subtract (), divide (/) and equals (=) work alright however the operation add (+) ain't working. When I try and add 2 + 2 I get the answer 22? If anyone could please help me with a solution to this problem I'd really appreciate it alot. Its probably something simple that I haven't noticed yet? Here is the bit of code just to show what I mean...
Code:
'Add (+) click event
Private Sub cmdAdd_Click()
If txtDisplay.Text = "" Then
MsgBox ("You must enter a number"), vbCritical
Else
FirstNumber = txtDisplay.Text
txtDisplay.Text = ""
Operation = "+"
End If
End Sub
'Divide (/) click event
Private Sub cmdDivide_Click()
If txtDisplay.Text = "" Then
MsgBox ("You must enter a number"), vbCritical
Else
FirstNumber = txtDisplay.Text
txtDisplay.Text = ""
Operation = "/"
End If
End Sub
'Multipy (*) click event
Private Sub cmdmultiply_Click()
If txtDisplay.Text = "" Then
MsgBox ("You must enter a number"), vbCritical
Else
FirstNumber = txtDisplay.Text
txtDisplay.Text = ""
Operation = "*"
End If
End Sub
'Subtract () click event
Private Sub cmdSubtract_Click()
If txtDisplay.Text = "" Then
MsgBox ("You must enter a number"), vbCritical
Else
FirstNumber = txtDisplay.Text
txtDisplay.Text = ""
Operation = ""
End If
End Sub
'Equals (=) click event
Private Sub cmdEquals_Click()
Select Case Operation
Case "+"
txtDisplay.Text = FirstNumber + txtDisplay
Case ""
txtDisplay.Text = FirstNumber  txtDisplay
Case "*"
txtDisplay.Text = FirstNumber * txtDisplay
Case "/"
txtDisplay.Text = FirstNumber / txtDisplay
End Select
End Sub
'Turn calculator off (same as Exit_Click() procedure)
Private Sub cmdOff_Click()
End
End Sub
Thanks for any responses and sorry about that long bit of code.
Numbers Only Help!
I am working on a notepad/html editor and I am going to allow the user to customize the background to any color they wish. I am using RGB, look:
Code:
Private Sub Command1_Click()
Picture1.BackColor = RGB(Text1, Text2, Text3)
End Sub
It works like this, 3 text boxes, maximum character = 3 and I want it to where only numbers 0255 are allowed and if they do anything other than that i want a msgbox to come up. I do want them to be able to type anything but numbers 0255, no letters, #,%,^,@,etc.. Is their any way to do this, please help!
Chr Numbers
Where can I find chr values for letters and signs ?
I need " (double quote) and space
Only Numbers
What do I have to do to make a textbox able to accept only numbers and not letters or symbols. I don't want to create a Messagebox containing an error message, I simply want when the user pushes a letterbutton or a symbolbutton, the textbox not to do anything (including not to erase the preexisting text). Thank you
Help With Numbers
I am writhing a program to creat an html table well the data in the field any ways.
4 fields
description
Paid
Deposit
SubTotal
enter the description then the amount paid or deposited then click create.
the color of the current row is determined by wether or not you are depositing(Green) or paying(red)
the problem is when you have a decimal number(ie .34) in the deposit it sees it as smaller than zero and vice versa with Paying.
Add Up Numbers
How can I talk all of the numbers in a column of an access db and add them up and display the total in a label? Some of the records may have blanks in them as well)
Get PC & NIC ID Numbers
Dear all,
Does anybody knows how to get a unique number from the PC Hardware in order to improve security of installed software ?
Please reply...
thanks and regards
alex
Numbers
Hi guys, this is probably a simple one  but i cant figure it out. Basically I have done throughout my project eg:
private sub
txtNow.text = "1"
txtThen.text = "1"
txtNow.text + txtThen.text
end sub
However, I want the answer to be 2, but ofcourse the answer is 11 as its set to text + text instead of number + number, is there anything I can easily do? Can i do something like txtNow.text + txtThen.text as numbers etc?
Any help would be greatly apreciated on this.
Kind Regards
Scott
Numbers
how can i make only accept numbers on a text box?
tanks
Max And Min Numbers...
I'm trying to make a max and min number program so when someone clicks Max command button then it generates 10 random numbers from 1 to 99 and also puts in a label box the max number thats in the 10 listed in the list box.
I got the numbers to appear in the list box but they are the same.
Thanks.
Help With Numbers
Hey,
I have a function that returns numbers. It can returns integer numbers (1,2,5) or numbers like 1.5, 8.5 0.5. Only These kind of numbers. The numbers represents hours.
Now i need to know if the number has values after the dot. It can be only 5 (x.5), but then i know its not a complete hour.
How can I check if the number is a complete hour or not?
Thanks
