• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2243
  • Last Modified:

How can I specify Euro ¬, Yen ¥, or US $ Currency Symbol to show on a Money data type regardless of the Windows Regional and Language Options

I have a Application in VB.net that is tied to a SQL DB. I can create a view in SQL with various tables which will give me essentially 4 columns. Column 1 is a string data type with "¬" (euro). Column 2 is a money data type let's say with a value of "2.50". Column 3 is a string data type with "¥" (yen). Column 4 is a money data type let's say with a value of "200.15".  What I want to do is have the application read Coulmn 2 as "¬2.50" and Column 4 as "¥200.15"

When I view any money data types I always see "$" (dollar) and I know that if I change my Windows Regional and Language Options from English(United States) to Japanese then I can always see "¥" (yen).  What I want to do is somehow override or ignore the Regional and Language Options so that I can display the currency symbol that I want.

Will it make a difference if column 2 is always a particular currency type and column 4 is always a particular currency type, versus having anything including  "¥" (yen), "¬" a(euro), $(dollar), and £(pound)?
0
Uniqueinc
Asked:
Uniqueinc
  • 5
  • 3
1 Solution
 
DhaestCommented:
You can format the strings giving the right culture.
See example below
Imports System.Globalization
Public Class Form1
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As Integer = 100
 
        ' Creates a CultureInfo for English in the U.S.
        Dim us As New CultureInfo("en-US")
        ' Displays i formatted as currency for us.
        Console.WriteLine(i.ToString("c", us))
 
        ' Creates a CultureInfo for dutch in belgium.
        Dim du As New CultureInfo("nl-BE")
        ' Displays i formatted as currency for dk.
        Console.WriteLine(i.ToString("c", du))
 
 
        ' Creates a CultureInfo for dutch in belgium.
        Dim ch As New CultureInfo("zh-CN")
        ' Displays i formatted as currency for dk.
        Console.WriteLine(i.ToString("c", ch))
    End Sub
End Class

Open in new window

0
 
rockiroadsCommented:
In your sql view, is it pssible to merge these wo columns?
I think you need to change your number column to a string
eg

SELECT COL1 + CAST(COL2 AS VARCHAR) AS VaLUEINEURO

or in vb.net, create a new string yourself using string concatenation

0
 
rockiroadsCommented:
vb.net string concatenation, assuming you have read the values in sCol1 and dCol2

sMergedCol = sCol1 & Convert.ToString(dCol2)

0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
rockiroadsCommented:
In that t-sql, I think you might need to specify a size on VARCAHAR eg VARCHAR(20). I think you can also use CONVERT. eg CONVERT(VARCHAR(20), col2)
0
 
UniqueincAuthor Commented:
Unfortunately I cannot change the data type because of other code using it which will not work if it is changed to a string type.

I forgot to mention I am using a VSFlexgrid on the User Interface to display the SQL data. Is it a vsflex property that i am missing? I hope what i am saying makes sense. In another area where the money/currency data type is used is it possible to make it so no Currency Symbol shows at all?
currency-symbol.JPG
0
 
UniqueincAuthor Commented:
Just found out the second part of my last post. To make "5.50" with a data type of money read as "5.50" instead of "$5.50" when linking record set to a VSFlex grid i just had to do the following code


Vsf.ColFormat(Col) = "0.00"

Open in new window

0
 
UniqueincAuthor Commented:
I think part of my solution is as you pointed out Dhaest. My problem now is the synatx as im pretty new to at this. I found the following parts of code, and there seems to be 2 places where it formats currency but how do i stick the culture info to it? Hopefully i have included all the necessary snippet to show you esentially what i am looking at.
Imports System.Globalization
Public Class Form1
 
Dim ch As New CultureInfo("zh-CN")
Dim fnCost As String = Schema.Record.Fields.Total_Cost.ToString
Dim summaryBand As UltraGridBand
summaryBand = m_UltraGrid.DisplayLayout.Bands(0)
   summaryBand.Columns(fnCost).Format = "c" 
 
   If summaryBand.Summaries.Count = 0 Then 
     summaryBand.Summaries.Add("TAmount", SummaryType.Sum, _ summaryBand.Columns(fnCost), SummaryPosition.UseSummaryPositionColumn)
     summaryBand.Summaries.Item("TAmount").DisplayFormat = "{0:c}"
   end if
end class

Open in new window

0
 
UniqueincAuthor Commented:
Thanks for pointing me in the right direction. Just needed to figure out where to put the CultureInfo
0
 
UniqueincAuthor Commented:
Found out where to format the cultureinfo in the comment above. After line 8 add the following code
' ch being the CultureInfo decalred in line 4
summaryBand.Columns(fnCost).FormatInfo = ch

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now