15,113,873 members
See more:
Hi All,

This is related to a question that I posed yesterday got an answer to and it worked! (thanks PK Fox & Original Griff) The problem is now that I am reading a value from a frequency counter of around 1.8432 MHz I need to convert this to hertz: 1843200 Hz and multiply by six to give 11059200 HZ I then need to send this out to the DUT.
The things are bothering me about this converting from a String to a Long, I can read in 1.8432 MHz and then use substring to get rid of the MHz (via blah.Substring(0, blah.Length-4). Can Decimal.Parse which I used yesterday for converting Amps to mA be used again bearing in mind I want to multiply by 6?
Does this question make sense?
Posted

## Solution 1

Yes - decimal.Parse converts it to a decimal value.
So multiply the decimal by 6 (or 6000 to convert from A to mA) and cast it as a long:
VB
`Dim mA As Long = CLng(Math.Truncate(Decimal.Parse("1.8432") * 6 * 1000))`
glennPattonInThePub3 10-Apr-14 9:40am

Thanks for that, I will try it! Mind you you start to get frustrated when you see you question poping up in Google....
glennPattonInThePub3 10-Apr-14 10:01am

Given it a go it does what I was finding earlier was problems getting the String to a Decimal so I could do the multiply by 6
glennPattonInThePub3 10-Apr-14 10:12am

FreqResult1823_Trimmed = System.Convert.ToDecimal(result1823A_Trimmed) appears to round to the decimal point.
glennPattonInThePub3 10-Apr-14 10:19am

Ah! CDec my old nemesis....
glennPattonInThePub3 10-Apr-14 10:21am

Accepting and closing question as I think I have a solution!!! Have a 5 as you got thinking the right way!