|
-
Jun 5th, 2000, 10:15 PM
#1
Thread Starter
New Member
I hope someone can help me. I'm using this code:
<code>
Dim exkl As Single
Dim inkl As Single
Dim euro As Single
Dim gesamt As Single
Dim zinsen As Single
Dim mwst As Single
Dim zwischensumme As Single
inkl = CSng(Form5.Text16.Text)
exkl = inkl - ust
exkl = Format(exkl, "##,##0.00")
zinsen = (inkl / 100) * 12
mwst = ((inkl + zinsen) / 100) * 20
gesamt = inkl + zinsen + mwst + 130
euro = (inkl + zinsen + 130) / 13.7603
zwischensumme = inkl + 130
zwischensumme = CSng(zwischensumme)
gesamt = Format(gesamt, "##,##0.00")
euro = Format(euro, "##,##0.00")
mwst = Format(mwst, "##,##0.00")
inkl = Format(inkl, "##,##0.00")
zinsen = Format(zinsen, "##,##00.00")
zwischensumme = Format(zwischensumme, "##,##0.00")
</code>
For example: Form5.Text16.Text = "200", zinsen should be 24,00 and gesamt should be 398,80 but I just get 24 for zinsen and 398,8 for gesamt.
How can i change it to this "##,##0.00" Format?
please help me
-
Jun 5th, 2000, 10:20 PM
#2
Fanatic Member
Check your regional settings.
We use a . for a decimal point and , for thousand separators here in the UK, but I developed an Excel VB prog for use in Holland and it went ape - because they had the exact reverse - , for decimals and . for thousand separator. How perverse....
-
Jun 5th, 2000, 10:32 PM
#3
Fanatic Member
The problem lies with your choice of variables.
You have chosen numeric variables so you can't save the format. You need to save the format in strings.
Good Luck.
Iain, thats with an i by the way!
-
Jun 5th, 2000, 11:29 PM
#4
Thread Starter
New Member
Thank you for your answers.
Iain:
please explain it more exactly?
I dont know what you mean. how can i save the format in strings
-
Jun 5th, 2000, 11:44 PM
#5
Fanatic Member
You will have to declare all of your variables as strings.
Then you can keep the format in the variable.
When you want to do calculations you will nedd to use the Val() Function.
Code:
Dim stCurFormat As String
Dim stEuro as String
stCurFormat = "##,##0.00"
stEuro = 12
stEuro = Format(stEuro, stCurFormat)
msgbox Format (Val(stEuro) * 10, stCurFormat)
[Edited by Iain17 on 06-06-2000 at 05:54 PM]
Iain, thats with an i by the way!
-
Jun 6th, 2000, 12:14 AM
#6
Thread Starter
New Member
ok, i understand
but i also want to calculate two single variables, therefore i can't use the val function
-
Jun 6th, 2000, 12:19 AM
#7
Fanatic Member
Why not?
Code:
msgbox val(stEuro) * val(stPound)
Iain, thats with an i by the way!
-
Jun 6th, 2000, 01:09 AM
#8
Thread Starter
New Member
doesn't the Val()-Function ingnore the comma
13.3 -> 13
13,3 -> 13 (for Europe)
Am i right?
-
Jun 6th, 2000, 01:28 AM
#9
Careful, guys! Alex is on the right track. The Val function stops at the first non-numeric character (after stripping out all spaces). For example, Val("12,345.67") will evaluate to 12. Not desirable! Val only recognizes the "." as a decimal separator, so it WILL accept "13.3" (i.e., it will convert it properly).
[Edited by BruceG on 06-06-2000 at 02:34 PM]
"It's cold gin time again ..."
Check out my website here.
-
Jun 6th, 2000, 03:30 AM
#10
Thread Starter
New Member
Thanks BruceG, i thought i was right.
In Austria we use the "," as a decimal separator. How can i solve my problem, when you look at my code, i've posted? I wonna change a string (ex. 125,5) to a single or a double, calculate with it and then send it to printer in a format like "##,##0.00" (ex. 1.250,50), but my code returns 1.250 or 1.250,5.
What's wrong with it?
alex
who won't give up
-
Jun 6th, 2000, 03:29 PM
#11
Fanatic Member
Sorry, i forgot the Val() funtiob was crap like that.
Use the Csng() function instead.
Iain, thats with an i by the way!
-
Jun 6th, 2000, 11:49 PM
#12
Thread Starter
New Member
Can anyone explain it to me
Hi
Thank you all for your answers!!!!!!
Could someone explain it to me, why the format-function does not work well with single variables (in my case)?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|