Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem with Greek comma (,) in a decimal value

Posted on 2003-03-17
7
Medium Priority
?
439 Views
Last Modified: 2012-06-27
Dear experts exchange users,

Imagine that I have two textboxes in which I want to enter decimal values and then insert these two values in an access database for later use.

When I'm entering a value like 5.5 or 5,5 the value finally inserted in the database is 55!
(I use English Windows with Greek Location and Greek Keyboard)

When I'm turning the Location to US I can't put 5,5 but instead 5.5 works fine.

My problem is that the final problem is intend to go to my UNI so it has to be all in GREEK language
with Greek Settings.

Further HINTS:
--------------
I DIM my variables as Singles

Then I pass the values of the textboxes into these two variables and I convert them with CSng to Singles.

Finally the fields in my MS Access database is declared as Single.
0
Comment
Question by:aktizol
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 10

Expert Comment

by:aeklund
ID: 8155776
Check your regional settings in control panel, make sure your decimal character is set to a comma.
0
 
LVL 1

Expert Comment

by:SilentRage
ID: 8155931
Private Sub Button1_Click()
Dim MyString As String, MySingle As Single
On Error Resume Next

    'change all comma's to periods
    MyString = Replace(Text1.Text, ",", ".")
    'convert the string to a single
    MySingle = CSng(MyString)
End Sub
0
 

Author Comment

by:aktizol
ID: 8159069
To AEKLUND:
-----------
I have tried all the possible combinations with the regional settings and didn't work.



To SILENTRAGE:
--------------
Nice thought, works almost fine. For some reason with Greek Regional Settings and Greek Keyboard I can't make work the dot (.) of the numpad. In Greece as a decimal comma we use this (,) so I change a little bit your replace

from:
MyString = Replace(Text1.Text, ",", ".")
to:
MyString = Replace(Text1.Text, ".", ",")

but the numpad dot (.) still doesn't work.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
SilentRage earned 150 total points
ID: 8159662
Keep it on greek regional settings.  We need to determine what VB will interpret as a decimal.  It may use the comma as a decimal cause you're in greek settings, but it may also use a period as the decimal considering VB was made by americans.  To find out what VB requires do this test:

Private Sub Button1_Click()
    Text1.Text = CStr(1 / 2)
End Sub

Maybe that will provide a bit of insight as to what you should be replacing with what.

Also, there's a program that comes with windows called Character Map.  In the Win2k version of the program (maybe 98/ME too I don't know) you can view the greek alphabetized version of the character list.  I ran it and it told me that the greek period is represented by the ascii value of 46.  This is the same as using the unicode or american alphabet.

Even if your keyboard does not have a key that will send a character 46 (period) to a textbox, you may still use another technique.  Hold down the ALT button and type 46 in your numpad.  Then release ALT.  A period should be printed to the textbox.
0
 

Author Comment

by:aktizol
ID: 8163297
To SILENTRAGE:
--------------
I will accept both of your comments as an answer because I use them both.
Thanx to your advice I found the solution in the following code...



------------------------------------------------------
Private Sub txtBathmoi_A_KeyPress(Index As Integer, KeyAscii As Integer)
   If KeyAscii = 44 Then
      KeyAscii = 46
   End If
End Sub
------------------------------------------------------
0
 

Author Comment

by:aktizol
ID: 8163304
no comment I commented on you before thanx once again ./..
0
 
LVL 1

Expert Comment

by:SilentRage
ID: 8169998
haha, good thinking!  I forgot that little trick completely.  Usually I use it to block invalid characters.

If KeyAscii = BadAscii Then
  KeyAscii = 0
End If

:D
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question