Tracker
 ASP PHP JavaScripts MySQL MS Access MSSQL VISUAL BASIC Subjects/Titles Post Text/Content
HOME    TRACKER    Visual Basic

# Dividing And Decimals

## I am trying to divide 30 / 60 and I get 0, instead of .5. I have tried converting the values to decimals but it still does not work.. Any suggestions?

Four Decimals From Textbox To Cell Problem, Two Decimals No Problem
I have this textbox where a price should be written...no problem in the old days but now that we have a new currency that obligates us to write FOUR DECIMALS...I cant get the job done anymore...

So the QUESTION : How do I put a price in a textbox and write it to an excel cell so that in the cell four decimals are shown...

Two I can do...but Four seems a problem ...

tried format(...,"0.0000")
format(...,"0,0000")

but they multiply or divide my input price...so format does not seem to work...unless you want TWO decimals

HELP

nitro

Dividing
Well I want to do what a user puts in one text box divided by what they put in another text box. I have a public variable called mining. This is what i put

txtCurrent.Text txtLevel.Text = mining

what did I do wrong?

Dividing
I have to do a program where you enter the amount of cents in an in put box and the program returns how many Quarters, Dimes, Nickles, and Pennies are needed to create the number entered. What should I use to divide the entered number, say its 92, and then divide it by 25 (A quarter) to return how many quarters are needed, then take the remainder and divide that by 10 ( a dime) and so on...

Dividing Without Dividing
I'm curious on how I would divide without using the '/' symbol and the '' symbol. It involves multiplying by a decimal or something. I've seen this before. I know C++ can do it using bit shifting. So how would I do it? Bare in mind, this is for speed purposes, so don't give me slow methods. Thanks in advance you all.

If you take to variables as integers and you divide them like so a/b = whatever it will = no biggy. But i am making something right now that it needs to tell you the percentage of something so i used this. (cor/tot) * 100
so that gives me the correct divided by the total times a hundred no problem until for example i get the total to = 19 and the cor = 3 then you get somthing like 6.33333333333333333% and thats no fun is there a way to make it round up or downso like 6.333 would be 6 or 6.9 would be 7 see what I mean. I tried using the other divide symbols ( , mod ) but they don't give me what I want so does anyone know please help!!!

------------------
Sincerely,
Chris
:-) ;-)

Quote:

just have fun out there and live life to the fullest while it is still here

Email pitbullcr7@aol.com

Dividing 0 By 0
I made a simple calculator just for practice and everything works except when i try to divide 0 by 0 i get an overflow error, is there a way around this?

Dividing Up An Image?
Hey everyone,

While looking through the files that came with card game I saw a picture that contained all of the 35 cards in it like a collage. In the game, the cards are displayed as separate objects. Is there some technique for diving up a picture and using separate cutouts? What is this all about?

Thanks.

- Dan

Dividing Calculations?
hi, i was just wondering how i could do this: what i need is a way to divide the a number and have the result of ONLY the whole number. so for example, 7 / 4 = 1, not 1.75

thanks

Dividing Digits
i hav 3 textboxes and a command button. when i press the button after entering a number in one box it sould divide to other two boxes.eg:-
text1=12345678

text2=1234
text3=5678
how can i do it?

Dividing A String
How do I divide a string, strData, that contains the information "str1|str2|str3|str4" so that each string of information in between the "|" gets assigned its own string?

Dividing Problem
hi,

ive created a program that can add, subtract, multiply and divide. The problem i have is that in the dividing section of the program it develops the numbers randomly and therefor most of the time the numbers created to divide dont match.

eg, 17 / 5

is there a way i can create numbers that match each other and can be divided like 10 / 2 = ?

cheers.

Dividing Cells In 2
Hey all,

If you are good with the VsFlexGrid control, i got a good one for you guys

Is there a way to divide a cell in 2

Like one cell will be to enter text and the other one will be to place a listBox.

Those 2 controls must stay in the same cell because if i put that line:
.ColComboList(.Col) = "..."
The cell is like a listBox(The user can not enter text) with a button that makes a calendar appeir that lets you enter a date in that cell.

But with that line:
.EditText = ""
The user can enter the date manually in that particular cell

What i am trying to do is put both option in the same cell so that the user will be able to enter the date from the calendar and manually.

But i can't put both line of coding in the same cell because the " .EditText = "" " won't have any affect and the cell will still be locked

Dividing Up A Site
Okay, I'm re-doing my eiSecure.com site, and anybody got any suggestions on how it should be divided up?

(Into what sections, specifically.)

I know I will have a button that says "Home" and a button that says "Forums", but what others should I have?

Dividing A Combo Box
hi

I've been trying to split a combo box into two columns
instead of using two combo boxes but i couldn't do it,

Dividing To Get A Remainder
I know that I did this about 3 years ago... but it's gone now

I'm pretty sure that it's a simple function, but it's funny how I can't seem to find the answer through either google or the VBCity search engine...

Anyway, I want to divide and get the remainder rather than the actual value of the division. I know this can be done by multiplying the decimal by the divisor, but that involves stripping the decimal off - if there's a faster way to do it, I'd love to know. Thanks!

-----------------------------
looks like another bug...

Dividing A VB Project
Hi,

I am working on a VB project which contains about 50 forms. I need to divide this project in five modules which were specified(each module contains about 5-10 forms). Can you help me with how to go about it. I am confused as to how exactly to divide my project into these modules...

Thankx,
Bye,
Nemani.

Dividing Variables Returns 0
Can anyone tell me what I am doing wrong here? I am trying to get "c" to return 100, but it only returns 0.

Code:
Private Sub test()
Dim a As Long
Dim b As Long
Dim c As Integer
b = 65535
For a = 1 To b
c = a b * 100
Next
MsgBox c
End Sub

Dividing A List By A Number...
If I wanted to divide a list index by 25 how would I do it...

So lstopp.listindex / 25

Dividing A Cell Into Rows
How will i make my flexgrid look like the ff:
the first column is the product, the second is the price.. i want the cell in the third column be divided depending on many sizes there are in 1 product..
if there is only 1, then there shouldnt be any dvision at all..
thanks

Dividing A Form - Caption
Hello, I'm trying to divide the caption of a form in three parts,
with three different allignments (left, center and right)...

Can anybody help me?

I need to divide a currency by x. I have x number of variables.
I then need to fill the variables with the Dividend and add the remainder to the last variable to account for every penny.

Im sorry, i know that was confusing... here's a scenario:

The total amount due is \$100
Let's say they want to make 3 PAYMENTS

I need to divide 100 into 3 payments which is \$33.33 each
but that would only total \$99.99

How can I code it so that the last payment will include the remainder?

So the payments should be: \$33.33, \$33.33, \$33.34

*Feels Foolish* Dividing
How do you divide in VB

I tried the '/' sign but that doesnt seem to divide

iVal3 = iVal1 + iVal2 / 2

Not working :O

*sorry*

Dividing The Word In The Sentece....
how to devide the words in 1 sentence????

Example:
'(input texts name)
txtArea.text="john c. garnet"

txtFName.text="john"
txtMName.text="c."
txtLName.text="garnet"

'(command button name)
cmbDivide

i will type the name in txtArea.text then when i click the cmbDivide button it will display the firstname in the "txtFName.text" and the middle name in "txtMName.text" and the last name in "txtLName.text" just like the examples in above...

Help plsss......

Dividing Whole Numbers Problem
I'm building a maths program for year 6 children.

Problem with division - I generate a random number between say 1 and 1000. I
want to generate another random number which when divided by the first
number gives a whole number answer. Any Idea how I could do this? Obviously
generating prime numbers is a bit of a problem as well!

Cheers,

Jack

Dividing A VB Project In To Modules
Hi,

I am working on a VB project which contains about 50 forms. I need to divide this project in five modules which were specified(each module contains about 5-10 forms). Can you help me with how to go about it. I am confused as to how exactly to divide my project into these modules...

Thankx,
Bye,
Nemani.

Option Button Dividing In A Form
I dont really need to know this, Ive just wondered for a while.
How would I have option buttons, where there can be more than one selected on a form, like 2 or 3 selections in the same form, without one in the new section cancelling out an older one?

No rush, I dont really need to know... I just couldnt find anything in search...

Dividing Time To Return An Integer!
Dim StartTime, CompStart As Date

Dim ResultTime As Date

StartTime = Form3.dtStartTime
CompStart = FormatDateTime(Form1.DataGrid1.Columns(8), vbLongTime)

ResultTime = CompStart - StartTime

Dim Divided, Divided2, Divided3, Divided4, counter As Integer

Divided = ((DatePart("n", ResultTime) / 12) - 1)

Right this code works perfectly except that if the ResultTime is 01:36:00, it returns 3....i.e. its dividing just 36 by 3, not the total time.
So what do i change the "n" in the DatePart to so that it will divided the total time not just the minutes! Could i convert the Result time to just minutes? How?

Dividing Deeper Than 15 Significant Digits?
Quick question, is there any way to divide (or any math function, really) deeper than the default 15 significant digits in visual basic?

Thanks

Dividing On Pages The HTML Report
Dear

I'd like to use the html page as report, but how can beginning of next printed page could be determinated? Frankly: I'd like to make header (with picture) on every new page in report and later the rest of report (until I get the end).
How the end of page of every part of report can be detected (based on choosen printer by user)?

Who knows the best solution?

Kind regards
Piotr

Flexgrid Adding, Substracting, Multiplying, And Dividing
well like the title said how can i have columns in my flexgrid do adding, substracting, multiplying, and dividing between columns????

How Can I Divide Text Into 2 Parts Without Dividing The Words
i have a text which is max. 50 characters.
i want to divide this text into two text.
but i don't want to divide the words. example the text;

"every day i learn new things in visual basic"

if i divide the text into two with left(,25) and right(,25) the result is this;

"every day i learn new thi"
"ngs in visual basic"

but i want to divide like this;

"every day i learn new"
"things in visual basic"

in brief text1 will be equal or less 25 char. text2 will be 25 or more.
it will depend on the text.

is there any comment.

Dividing Output Into Seperate Text Files
ok, situation looks like this:

i have a rich text box filled with words, say, 30,000 words for instance all on different lines. i need to be able to press a button and divide this richtext1.text into output of 30 text files with 1,000 words in each of them

i need it to work with any number of words, so say if there were 23.3k words in the text box it would make 24 files, and the fourth would have 300 words instead of 1000.

ive been toying around but unable to figure it out, any help it greatly appreciated!

Dividing A Day Into X Number Or Equil Lengths Of Time
I've recently make a background changer, it changes the background every 15 minutes. I have a 96 pictures stored in a directory, that make a day-night cycle. This works fine.

I want to extend the functionality so that i can choose a directory, and it will count the files within it, then workout when the background has to change to each one.

Thanks for any replies.

Dividing Large # Of Files Into Seprate Directories?
I am doing a data conversion and basically I need to seperate a large group of files into smaller groups. Another seperate program (not discussed here) will convert these smaller groups.
The initial files I am working with are over 1 million and are all in one directory. They are all numeric files with 5 to 6 digits each. What I would like to do to improve the performance of the conversion by seperating the 1 million files into less than 1000 in sub directories.
So we would have to scan all the current files in the one directory, then create directories as needed (dynamically). I believe the best way to do this is read the files from right to left. Stopping at the fourth number. Then each number from the fourth # to the far left # would have sub folders created ranging from 0-9 for each number. This would allow each folder to contain less than 1000 files.
Ideally the program would work something like this:

The User push "go" button
There is a pre defined hard coded location of directory with 1 million records.
The program would scan files in directory
The program would read from right to left skip over first three numbers (we want to put less that 1000 records in each folder). Each of the digits, left of the first three number require a sub folder numbered 0-9). Possibly use a dynamic array to save values of dir names.
Make directories based on file names. copy files and place in appropriate numbered directory.
end

Does this make more sense? Or does anyone have ideas on what direction this should take?

sample code is appreciated.

Thanks in advance to anyone who can help.

Decimals Of PI
I want to calculate PI.. I found a formula and now i'm using it. The only problem is that this formula saves pi as a number. And vb only saves 14 decimals for a number. I want about 100. PS: The formula is said to calculate around 140 decimals (as it is below).. Pls help..

Code:
Dim K1, K2, K3, K4, K5, K6 As Variant

Function Fact(n As Variant)
p = 1
For i = 1 To n
p = p * i
Next i
Fact = p
End Function

Function Putere(a, b As Variant)
p = 1
For i = 1 To b
p = p * a
Next i
Putere = p
End Function

Function Pl(n As Variant)
If n / 2 = Int(n / 2) Then
Pl = 1
Else
Pl = -1
End If
End Function

Function Sum(i As Variant)
Sum = Pl(i) * Fact(6 * i) * (K2 + i * K1) / (Fact(i) * Fact(3 * i) * Putere(8 * K4 * K5, i))
End Function

Private Sub Command1_Click()
K1 = 545140134
K2 = 13591409
K3 = 640320
K4 = 100100025
K5 = 327843840
K6 = 53360
For i = 0 To 10
s = s + Sum(i)
Next i
PI = K6 * Sqr(K3) / s
txtPI.Text = Str(PI)
End Sub

Help On Decimals
this

2.0833 - 2

gives me this

8.33333299999999E-02

but i want 0.0833

can some one help me...thx!

Again With The Decimals
I have a text box and I dont want the user to be able to type:
1. Any character that isnt a number or a "."
2. More than 2 numbers after the "." decimal point

As you may have guest, this is for a price.

Big Decimals To Hex :S

I have an 8 byte decimal (example: 4138022424138707046)
I need to turn it to hex.
I used a function dectohex...

Code:
Function DecToHex(ByVal x As Variant) As String
Dim y%: x = CDec(x)
Do
y = (x / 16 - Int(x / 16)) * 16
If y < 10 Then DecToHex = y & DecToHex Else DecToHex = Chr\$(y + 55) & DecToHex
x = Int(x / 16)
Loop While x
End Function
and then TRY call it like

Code:
Private Sub Command2_Click()
Text1.Text = DecToHex(4138022424138707046)
End Sub
but what happens is every time i change dectohex() it changes 4138022424138707046 to 4.13802242413871E+18
I'm confused here.
4138022424138707046 converted to hex, then converted to ascii should bring up 9m5xwcpf, instead it brings up "9m5xwc{ð" because of the crap that VB changed it to.

I need a solution :
if anyone could help, it would be appreciated alot!

me

No More Than Two Decimals
Hey,
How could i limit the number of decimal in a calculation in a query. For example :
Select ((Eheures + Eminutes/60)*CoutHoraire) as InfoHoraire ....

This query works fine but the result can sometimes have an undelimited number of decimal !!! (depends on the Eminutes) I would like to be sure to get only 2 decimals.

Help With No Decimals?
VB Code:
Private Sub cmdLoop_Click() 'Code for Guess number'By scott 'Declare variables used in the programDim counter As SingleDim UsersGuess As SingleDim number As Single 'Start counter at 0counter = 0 'Generate the random numbernumber = Int(Rnd * 20) + 1 Do'Asks user for the random numberUsersGuess = InputBox("please enter a number between 1 and 20")     If UsersGuess < 1 Then        MsgBox ("Enter a whole number between 1 and 20, please.")    ElseIf UsersGuess > 20 Then        MsgBox ("Enter a whole number between 1 and 20, please.")    ElseIf UsersGuess = number Then            counter = counter + 1        MsgBox ("CORRECT! You done it in" & " " & counter & " " & "Tries")    ElseIf UsersGuess < number Then        MsgBox ("My number is bigger than your guess.")            counter = counter + 1    ElseIf UsersGuess > number Then        MsgBox ("My number is lower than your guess.")            counter = counter + 1    End If    Loop Until UsersGuess = numberEnd Sub

Well the aim of this is for my school work.... but i dont know how to make it so you cant enter decimals??

Task: a program is required to promt the user to guess a randomly-chosen whole number between 1 and 20. The input should be validated. If the guess is incorrect, the user should be told if the target number is bigger or smaller. This process should continue until the target number is guessed correctly. The user should then be told how many valid guesses were made.

So i've pretty much completed task, except for the part whole numbers.. So theres not allowed to be the input e.g. 4.9 or something? only Whole numbers.. Anyone help?

~ Thanks Scott.

Help On Decimals
i have this scenario..

100.81 = the value must be 100.81

the problem:
100.80 = the value is 100.8

it must be 100.80

anyone willing to help on how to code on this one? thanks!

Decimals
Hi there

I need to work with a number that uses decimals.
Is there any other variable type other than currency that allows the use of decimals.
i want to store the outer diameter of cylinders.

Any ideas ??

Decimals
Hi all,

I am using MS Access 2000 as back-end. I have a table having a data type of double or single. Things are working fine normally. But sometimes the decimals of the field gets bugged up. For instance, 21241.05 is saved as 21241.05078125.

My questions is why the number of digits after decimal gets increased automatically. Is there any bug or problem with the table structure.

Prakash

Hot To Set Decimals?
I have a double like this:
4.2364564

and would like to have it this way:
4.24

How can I do it?

Thanks.
JCI.

Decimals
i am making a kinetic energy calculator but when i enter the weight i cant put a decimal in and have it come out correctly... can someone help me (o by the way the answer comes out 2 zero wher u use a decimal)

Decimals
Good afternoon.

I have program that uses . as a decimal place. My program is now running in Denmark and they use , as the decimal point. This does create a little problem for me.

I use the Val function so that, when running in demark, if the program uses a . it is displayed as a ,. But now I need to do it the otherway around. If the user enters a , I need to save it a . because a , upsets my comma delimited file.

What I thought of doing is breaking up the number into interger and fraction and then concatinating it together with a .

I know the Int function returns the interger portion, but what function can I use to return the fraction. I know I could mid string, but it is not so elligant.

I hope this all makes sense. Please let me know if I should explain better.

Thanks
Tam

Decimals?
Is there an easy way to limit the number of decimal places when doing calculations and displaying in a label? I would like 2decimal places.

Decimals
I'm calculating numbers and then I put them into text-boxes, but the nubmer has to many decimals! How can I get only two decimals in the number?

Decimals
How do I get VB to return and decimal amount. For example, I want to return
.08 from the value 6.08, with just a single line of code. The numbers used
for this will be dynamic. Any hints would be greatly appreciated.

Kevin Baker
Client/Server Developer
Mutual of Enumclaw Insurance Co.
email@removed
(360)825-2591 x3471