PC Review


Reply
Thread Tools Rate Thread

Decimal point

 
 
Flemming Jørgensen
Guest
Posts: n/a
 
      6th Apr 2008
Hi

I have a code like this
PrintSheet.Range("L24") = "=" & dasheet.Cells(2, 1) & "*" &
adsheet.Cells(adix, 6) & "/" & adsheet.Cells(40, 6)

and when the user put in like 500,35 in dasheet.Cells(2,1) it creates an
runtime error. The problem dosn't occur when they ttype in 500.35.

But im danish - and in denmark we use "," (comma) as decimal point.

How can I change VB to use "," as decimail point instead of "."

Thanks for any help
 
Reply With Quote
 
 
 
 
troysteadman@yahoo.co.uk
Guest
Posts: n/a
 
      6th Apr 2008
On 6 Apr, 14:59, Flemming Jørgensen <Flemming
Jørgen...@discussions.microsoft.com> wrote:
> Hi
>
> I have a code like this
> PrintSheet.Range("L24") = "=" & dasheet.Cells(2, 1) & "*" &
> adsheet.Cells(adix, 6) & "/" & adsheet.Cells(40, 6)
>
> and when the user put in like 500,35 in dasheet.Cells(2,1) it creates an
> runtime error. The problem dosn't occur when they ttype in 500.35.
>
> But im danish - and in denmark we use "," (comma) as decimal point.
>
> How can I *change VB to use "," as decimail point instead of "."
>
> Thanks for any help


Use S=Replace (S, ",". ".") to replace commas with full stops? Excel
is very liberal in letting you treat numbers as text, and generally
accepts them back as numbers.
 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      6th Apr 2008
Hi Flemming, you can set your system by clicking Tools>Option>International
and then choose the type of separator you want to use. However, when you
interface with other systems, you will need to know what they are using or it
could cause problems between the two.

"Flemming Jørgensen" wrote:

> Hi
>
> I have a code like this
> PrintSheet.Range("L24") = "=" & dasheet.Cells(2, 1) & "*" &
> adsheet.Cells(adix, 6) & "/" & adsheet.Cells(40, 6)
>
> and when the user put in like 500,35 in dasheet.Cells(2,1) it creates an
> runtime error. The problem dosn't occur when they ttype in 500.35.
>
> But im danish - and in denmark we use "," (comma) as decimal point.
>
> How can I change VB to use "," as decimail point instead of "."
>
> Thanks for any help

 
Reply With Quote
 
Flemming Jørgensen
Guest
Posts: n/a
 
      6th Apr 2008
Foe some reason I dont have option "International" on that menu.
I'm using VB 6.5 - i dont know if thats the reason.
But thanks anyway


"JLGWhiz" wrote:

> Hi Flemming, you can set your system by clicking Tools>Option>International
> and then choose the type of separator you want to use. However, when you
> interface with other systems, you will need to know what they are using or it
> could cause problems between the two.
>
> "Flemming Jørgensen" wrote:
>
> > Hi
> >
> > I have a code like this
> > PrintSheet.Range("L24") = "=" & dasheet.Cells(2, 1) & "*" &
> > adsheet.Cells(adix, 6) & "/" & adsheet.Cells(40, 6)
> >
> > and when the user put in like 500,35 in dasheet.Cells(2,1) it creates an
> > runtime error. The problem dosn't occur when they ttype in 500.35.
> >
> > But im danish - and in denmark we use "," (comma) as decimal point.
> >
> > How can I change VB to use "," as decimail point instead of "."
> >
> > Thanks for any help

 
Reply With Quote
 
Flemming Jørgensen
Guest
Posts: n/a
 
      6th Apr 2008
I'm sorry to say that is dosnt work
MsgBox dasheet.Cells(2, 1)

dasheet.Cells(2, 1) = Replace(dasheet.Cells(2, 1).Value, ",", ".")

MsgBox dasheet.Cells(2, 1)

Both Msgbox shows comma - and the program dumps

"(E-Mail Removed)" wrote:

> On 6 Apr, 14:59, Flemming Jørgensen <Flemming
> Jørgen...@discussions.microsoft.com> wrote:
> > Hi
> >
> > I have a code like this
> > PrintSheet.Range("L24") = "=" & dasheet.Cells(2, 1) & "*" &
> > adsheet.Cells(adix, 6) & "/" & adsheet.Cells(40, 6)
> >
> > and when the user put in like 500,35 in dasheet.Cells(2,1) it creates an
> > runtime error. The problem dosn't occur when they ttype in 500.35.
> >
> > But im danish - and in denmark we use "," (comma) as decimal point.
> >
> > How can I change VB to use "," as decimail point instead of "."
> >
> > Thanks for any help

>
> Use S=Replace (S, ",". ".") to replace commas with full stops? Excel
> is very liberal in letting you treat numbers as text, and generally
> accepts them back as numbers.
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      6th Apr 2008
JLGWhiz's suggestion is for the Tools item in the Excel worksheet's menu
bar, not the one in the VB editor.

Rick


"Flemming Jørgensen" <(E-Mail Removed)> wrote in
message news:83678316-B65D-46D7-AF44-(E-Mail Removed)...
> Foe some reason I dont have option "International" on that menu.
> I'm using VB 6.5 - i dont know if thats the reason.
> But thanks anyway
>
>
> "JLGWhiz" wrote:
>
>> Hi Flemming, you can set your system by clicking
>> Tools>Option>International
>> and then choose the type of separator you want to use. However, when you
>> interface with other systems, you will need to know what they are using
>> or it
>> could cause problems between the two.
>>
>> "Flemming Jørgensen" wrote:
>>
>> > Hi
>> >
>> > I have a code like this
>> > PrintSheet.Range("L24") = "=" & dasheet.Cells(2, 1) & "*" &
>> > adsheet.Cells(adix, 6) & "/" & adsheet.Cells(40, 6)
>> >
>> > and when the user put in like 500,35 in dasheet.Cells(2,1) it creates
>> > an
>> > runtime error. The problem dosn't occur when they ttype in 500.35.
>> >
>> > But im danish - and in denmark we use "," (comma) as decimal point.
>> >
>> > How can I change VB to use "," as decimail point instead of "."
>> >
>> > Thanks for any help


 
Reply With Quote
 
Flemming Jørgensen
Guest
Posts: n/a
 
      6th Apr 2008

I have looked for it in excel (2007) - but I couldn't find it.
I seach help for international and found:
MsgBox "The decimal separator is " & _
Application.International(xlDecimalSeparator)

and putting that into the program it showed "," comma
So im lost.

"Rick Rothstein (MVP - VB)" wrote:

> JLGWhiz's suggestion is for the Tools item in the Excel worksheet's menu
> bar, not the one in the VB editor.
>
> Rick
>
>
> "Flemming Jørgensen" <(E-Mail Removed)> wrote in
> message news:83678316-B65D-46D7-AF44-(E-Mail Removed)...
> > Foe some reason I dont have option "International" on that menu.
> > I'm using VB 6.5 - i dont know if thats the reason.
> > But thanks anyway
> >
> >
> > "JLGWhiz" wrote:
> >
> >> Hi Flemming, you can set your system by clicking
> >> Tools>Option>International
> >> and then choose the type of separator you want to use. However, when you
> >> interface with other systems, you will need to know what they are using
> >> or it
> >> could cause problems between the two.
> >>
> >> "Flemming Jørgensen" wrote:
> >>
> >> > Hi
> >> >
> >> > I have a code like this
> >> > PrintSheet.Range("L24") = "=" & dasheet.Cells(2, 1) & "*" &
> >> > adsheet.Cells(adix, 6) & "/" & adsheet.Cells(40, 6)
> >> >
> >> > and when the user put in like 500,35 in dasheet.Cells(2,1) it creates
> >> > an
> >> > runtime error. The problem dosn't occur when they ttype in 500.35.
> >> >
> >> > But im danish - and in denmark we use "," (comma) as decimal point.
> >> >
> >> > How can I change VB to use "," as decimail point instead of "."
> >> >
> >> > Thanks for any help

>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      6th Apr 2008
When did you tell us you were using Excel 2007? I think you'll find the
majority of Excel users have not moved up to XL2007, so most of the answers
here lean to the prior versions. For future questions you may post, it would
be a good idea to include that fact that you are using XL2007 so that those
able to answer your question as it relates to that version will be alerted.

As to JLGWhiz's suggestion (which I don't know if it will solve your problem
or not), you will find that option by clicking on the Office Button and then
on Excel Options, select the Advanced item from the left-hand listing an
look to the lower part of the Editing Options section in the dialog area on
the right side. Uncheck the "Use system separators" checkbox and enter the
appropriate separators in the indicated textboxes.

Rick


"Flemming Jørgensen" <(E-Mail Removed)> wrote in
message news:5D24BD04-D1DD-49B9-A978-(E-Mail Removed)...
>
> I have looked for it in excel (2007) - but I couldn't find it.
> I seach help for international and found:
> MsgBox "The decimal separator is " & _
> Application.International(xlDecimalSeparator)
>
> and putting that into the program it showed "," comma
> So im lost.
>
> "Rick Rothstein (MVP - VB)" wrote:
>
>> JLGWhiz's suggestion is for the Tools item in the Excel worksheet's menu
>> bar, not the one in the VB editor.
>>
>> Rick
>>
>>
>> "Flemming Jørgensen" <(E-Mail Removed)> wrote
>> in
>> message news:83678316-B65D-46D7-AF44-(E-Mail Removed)...
>> > Foe some reason I dont have option "International" on that menu.
>> > I'm using VB 6.5 - i dont know if thats the reason.
>> > But thanks anyway
>> >
>> >
>> > "JLGWhiz" wrote:
>> >
>> >> Hi Flemming, you can set your system by clicking
>> >> Tools>Option>International
>> >> and then choose the type of separator you want to use. However, when
>> >> you
>> >> interface with other systems, you will need to know what they are
>> >> using
>> >> or it
>> >> could cause problems between the two.
>> >>
>> >> "Flemming Jørgensen" wrote:
>> >>
>> >> > Hi
>> >> >
>> >> > I have a code like this
>> >> > PrintSheet.Range("L24") = "=" & dasheet.Cells(2, 1) & "*" &
>> >> > adsheet.Cells(adix, 6) & "/" & adsheet.Cells(40, 6)
>> >> >
>> >> > and when the user put in like 500,35 in dasheet.Cells(2,1) it
>> >> > creates
>> >> > an
>> >> > runtime error. The problem dosn't occur when they ttype in 500.35.
>> >> >
>> >> > But im danish - and in denmark we use "," (comma) as decimal point.
>> >> >
>> >> > How can I change VB to use "," as decimail point instead of "."
>> >> >
>> >> > Thanks for any help

>>
>>


 
Reply With Quote
 
Flemming Jørgensen
Guest
Posts: n/a
 
      6th Apr 2008
Hi Rick
Im not very familiar with neither Excel or VB. Actually it is the first time
im trying do something with it. I didnt know that all you sharks didnt use
2007 - so sorry about that.
But I still cant find what you are suggesting.
But I'm in the proces of changing my code so that I use variables instead of
using cells directly.


This:
HVfast = daSheet.Range("F2")
PrintSheet.Range("L24") = HVfast * Kvm / TotalKvm
instead og this
'PrintSheet.Range("L24") = "=" & dasheet.Cells(2, 1) & "*" &
adsheet.Cells(adix, 6) & "/" & adsheet.Cells(40, 6)

I seems to do the job.
But thanks for your help


"Rick Rothstein (MVP - VB)" wrote:

> When did you tell us you were using Excel 2007? I think you'll find the
> majority of Excel users have not moved up to XL2007, so most of the answers
> here lean to the prior versions. For future questions you may post, it would
> be a good idea to include that fact that you are using XL2007 so that those
> able to answer your question as it relates to that version will be alerted.
>
> As to JLGWhiz's suggestion (which I don't know if it will solve your problem
> or not), you will find that option by clicking on the Office Button and then
> on Excel Options, select the Advanced item from the left-hand listing an
> look to the lower part of the Editing Options section in the dialog area on
> the right side. Uncheck the "Use system separators" checkbox and enter the
> appropriate separators in the indicated textboxes.
>
> Rick
>
>
> "Flemming Jørgensen" <(E-Mail Removed)> wrote in
> message news:5D24BD04-D1DD-49B9-A978-(E-Mail Removed)...
> >
> > I have looked for it in excel (2007) - but I couldn't find it.
> > I seach help for international and found:
> > MsgBox "The decimal separator is " & _
> > Application.International(xlDecimalSeparator)
> >
> > and putting that into the program it showed "," comma
> > So im lost.
> >
> > "Rick Rothstein (MVP - VB)" wrote:
> >
> >> JLGWhiz's suggestion is for the Tools item in the Excel worksheet's menu
> >> bar, not the one in the VB editor.
> >>
> >> Rick
> >>
> >>
> >> "Flemming Jørgensen" <(E-Mail Removed)> wrote
> >> in
> >> message news:83678316-B65D-46D7-AF44-(E-Mail Removed)...
> >> > Foe some reason I dont have option "International" on that menu.
> >> > I'm using VB 6.5 - i dont know if thats the reason.
> >> > But thanks anyway
> >> >
> >> >
> >> > "JLGWhiz" wrote:
> >> >
> >> >> Hi Flemming, you can set your system by clicking
> >> >> Tools>Option>International
> >> >> and then choose the type of separator you want to use. However, when
> >> >> you
> >> >> interface with other systems, you will need to know what they are
> >> >> using
> >> >> or it
> >> >> could cause problems between the two.
> >> >>
> >> >> "Flemming Jørgensen" wrote:
> >> >>
> >> >> > Hi
> >> >> >
> >> >> > I have a code like this
> >> >> > PrintSheet.Range("L24") = "=" & dasheet.Cells(2, 1) & "*" &
> >> >> > adsheet.Cells(adix, 6) & "/" & adsheet.Cells(40, 6)
> >> >> >
> >> >> > and when the user put in like 500,35 in dasheet.Cells(2,1) it
> >> >> > creates
> >> >> > an
> >> >> > runtime error. The problem dosn't occur when they ttype in 500.35.
> >> >> >
> >> >> > But im danish - and in denmark we use "," (comma) as decimal point.
> >> >> >
> >> >> > How can I change VB to use "," as decimail point instead of "."
> >> >> >
> >> >> > Thanks for any help
> >>
> >>

>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      6th Apr 2008
See inline comments...

>> When did you tell us you were using Excel 2007? I think you'll find the
>> majority of Excel users have not moved up to XL2007, so most of the
>> answers
>> here lean to the prior versions. For future questions you may post, it
>> would
>> be a good idea to include that fact that you are using XL2007 so that
>> those
>> able to answer your question as it relates to that version will be
>> alerted.
>>
>> As to JLGWhiz's suggestion (which I don't know if it will solve your
>> problem
>> or not), you will find that option by clicking on the Office Button and
>> then
>> on Excel Options, select the Advanced item from the left-hand listing an
>> look to the lower part of the Editing Options section in the dialog area
>> on
>> the right side. Uncheck the "Use system separators" checkbox and enter
>> the
>> appropriate separators in the indicated textboxes.

>
> Im not very familiar with neither Excel or VB. Actually it is the first
> time
> im trying do something with it. I didnt know that all you sharks didnt use
> 2007 - so sorry about that.


It's not that *we* don't have XL2007, it is that most people asking
questions on the newsgroups don't have it. So, when the version of Excel
isn't mentioned, we assume the version is not XL2007 (whose user interface
is different than its predecessors).

> But I still cant find what you are suggesting.


The Office Button is that big round icon in the upper left corner of the
Excel window. If you click it, you will see a dialog box; at the bottom of
the dialog box are two buttons; the left one is labeled "Excel Options". If
you click it, a new dialog box appears with a listing of items along the
left hand side. One of those items is "Advanced"; click it and the right
hand panel will change. The option I was referring you to is located in the
section with the header of "Editin options" (it's the first section in the
panel). At the bottom of that section (just above the section header "Cut,
copy, and paste") is a check box labeled "Use system separators" which
should be checked by default. If you uncheck it, the two textboxes (labeled
"Decimal separator" and "Thousands separator") will become active and you
can change the separator symbols that Excel will use from them.

> But I'm in the proces of changing my code so that I use variables instead
> of
> using cells directly.
>
> <<<<snip>>>>
>
> I seems to do the job.


So then I guess we can assume your problem is solved at this point.

Rick

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting 2-place decimal value to floating point decimal number with leading zero Kermit Piper Microsoft Excel Misc 3 18th Mar 2006 06:20 PM
FIXED 2 DECIMAL PLACES, MUST ENTER ALL ZEROES AFTER DECIMAL POINT. =?Utf-8?B?U1VLWUtJVFRZ?= Microsoft Excel Misc 3 6th Jul 2005 01:50 PM
setting the decimal variable to include 2 numbers after decimal point? Scott Microsoft VB .NET 1 3rd Mar 2005 10:05 PM
C# - C sharp - String to decimal, decimal point disappears! BA Microsoft C# .NET 7 2nd Mar 2005 08:43 AM
Decimal class now preserves trailing zeroes after the decimal point Uncle Goh Microsoft Dot NET Framework 0 11th Sep 2003 09:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:30 PM.