Peso Sign Format in DataGridViewCell? - vb.net

I need my DG's second column to have "Php" (Philippine Peso) which is the DG is bound in a table, and the field set to "Currency". I've tried a lot of Googling for this but they just don't work. Also something about the "CultureInfo" is really not clear to me. I just use this and have a dollar sign.
DataGridView1.Columns(1).DefaultCellStyle.Format = "c"
Can someone teach me some possible ways how to have Php Currency?
I also tried this just in case a miracle happens lol.
DataGridView1.Columns(1).DefaultCellStyle.Format = "fil-PH"
Any help and ideas greatly appreciated!
P.S.
I transferred this project in my laptop and it successfully shows "Php". Maybe it has something to do with manufacturing history already.
Newbie coder here.

First, you need the correct currency format which is uppercase C.
Me.DataGridView1.Columns(1).DefaultCellStyle.Format = "C"
Then you need the correct culture info:
Me.DataGridView1.Columns(1).DefaultCellStyle.FormatProvider = Globalization.CultureInfo.GetCultureInfo("en-PH")
You can also assign a thread specific culture info. See my answer in this post:
Questions on localization/globalization of Ctype & .ToString

Related

Object name contains more than the maximum prefixes allowed

I have seen a lot of questions about this but I couldn't find the correct answer for me which works.
The object which triggers the problem is like
test123.de.company.com.Database.dbo.Table
Test123.de.company.com
is the database Server.
Object name contains more than the maximum prefixes allowed
I have tried to write it like this [test123.de.company.com].Database.dbo.Table just like [test123.de.company.com].[Database].[dbo].[Table]
Can you tell me what's wrong with this?
Please try this:
["test123.de.company.com"].[Database].[dbo].[Table]
OP also encountered a new problem after implementing this solution above. OP said:
Thank you! This worked for me. To be more precise, the join is for a
view and if I save/close and then later get back to the design option
the quote marks are removed and there is [test123.de.company.com] left
over and the error returns. Is there a way to keep them fixed?
Otherwise if I change anything I always have to add the quote marks
again and again
Then with the help of DaleK that problem also was solved. DaleK:
Don't use the design option, script it as alter instead

How to determine Thousands Separator using Format in VBA

I would like to determine the Thousand Separator used while running a VBA Code on a target machine without resolving to calling system built-in functions such as (Separator = Application.ThousandsSeparator).
I am using the following simple code using 'Format':
ThousandSeparator = Mid(Format(1000, "#,#"), 2, 1)
The above seems to work fine, and would like to confirm if this is a safe method of doing it without resorting to system calls.
I would expect the result to be a single char string in the form of , or . or ' or a Space as applicable to the locale on the machine.
Please note that I want to only use a language statement such as Format or similar (no sys calls). Also this relates to Thousands Separator not Decimal Separator. This article Using VBA to detect which decimal sign the computer is using does not help or answer my question. Thanks
Thanks in advance.
The strict answer to whether it is safe to use Format to get the thousands separator is No.
E.g. on Windows, it is possible to enter up to three characters into the Thousands Separator field in the regional settings in the control panel.
Suppose you enter asd and click OK.
If you now call Format(1000, "#,#") it will give you 1a000. That is only the first letter of your thousands separator. You have failed to retrieve it correctly.
Reading the registry:
? CreateObject("WScript.Shell").RegRead("HKCU\Control Panel\International\sThousand")
you get back asd in full.
To be fair, the Excel international properties do not seem to be of much help either. Application.International(xlThousandsSeparator) in this situation will return the separator originally defined in your computer's locale, not the value you've overridden it to.
Having that said, the practical answer is Yes, because it would appear (and if you happen to know for sure, please post an answer here) that there is no culture with multi-char thousand separator (even in China where scary things like 1ε„„2345δΈ‡6789 or 1ε„„2345萬6789 exist, they happen to be represented with just one UTF-16 character), and you probably are happy to ignore the people who decided to play with their locale settings in that fashion.

Dollar and exclamation mark (bang) symbols in VTL

I've recently encountered these two variables in some Velocity code:
$!variable1
!$variable2
I was surprised by the similarity of these so I became suspicious about the correctness of the code and become interested in finding the difference between two.
Is it possible that velocity allows any order of these two symbols or do they have different purpose? Do you know the answer?
#Jr. Here is the guide I followed when doing VM R&D: http://velocity.apache.org/engine/1.7/user-guide.html
Velocity uses the !$ and $! annotations for different things. If you use !$ it will basically be the same as a normal "!" operator, but the $! is used as a basic check to see if the variable is blank and if so it prints it out as an empty string. If your variable is empty or null and you don't use the $! annotation it will print the actual variable name as a string.
I googled and stackoverflowed a lot before I finally found the answer at people.apache.org.
According to that:
It is very easy to confuse the quiet reference notation with the
boolean not-Operator. Using the not-Operator, you use !${foo}, while
the quiet reference notation is $!{foo}. And yes, you will end up
sometimes with !$!{foo}...
Easy after all, shame it didn't struck me immediately. Hope this helps someone.

How to parse whether a string is a valid US currency value

Originally I was using
Decimal.TryParse(input, New Decimal)
to figure out of user input is valid money. This works for most cases, except I only want to accept money within 2 digits, so "10.001" should not be accepted.
I looked all over SO for this simple and I imagine common issue but could not find an answer.
Mark in the discussion solved this for me. Thanks! Here's the VB.net code for what I was looking for:
Dim regex As Regex = New Regex("[0-9]?[0-9]?(\.[0-9]?[0-9]$)")
Dim match As Match = regex.Match(input)
If Not match.Success Then

How to calculate satellite position using ephemerides data

I got a problem regarding ephemerides data.
The description of the ephemerides data is located here:
http://www.navcen.uscg.gov/pubs/gps/sigspec/gpssps1.pdf
I can extract the bits/bytes that are important. I just don't know how to interprete them.
It seems there is no information about that. I guess from the document that it should contain Keplerian data to calculate the position of a satellite in "WGS-84 Earth-Centered Earth-Fixed" format, which is what I need.
This document says that I can calculate the final position "utilizing a variation of the equations shown in Table 2-15"
The parameters that I need to fill into this terms are
Cus Cuc Crc Crs Cic Cis IDOT toe io
I know how long these parameters are, but not where to start to read them inside of the datastream
Looking at page 32, I see that they are there, but where they are inside of this block of "words", thats a secret for me.
Can anyone help ?
I dont ask anyone to read the whole pdf, thats a bit too much, but maybe someone has a deep knowledge regarding this topic already.
And this terms are a bit confusing, because some of them are defined recursive
A = sqrt(A^2)
vk = something * Ek
Ek = something * vk
Thanks in advance
I'm currently working on similar problems. So far the opensource library gnss-sdr has been of great help. Especially src/core/system_parametes/gps_navigation_message.cc where the function
int Gps_Navigation_Message::subframe_decoder(char *subframe)
which decodes and stores each subframe is defined.