是否有一个'容易'转换VB中的指数 [英] Is there an 'easy' to convert exponents in VB

查看:62
本文介绍了是否有一个'容易'转换VB中的指数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



这与我昨天提出的问题有关,而且有效! (感谢PK Fox和Original Griff)现在的问题是我正在从1.8432 MHz左右的频率计数器中读取一个值我需要将其转换为赫兹:1843200赫兹并乘以6得到11059200 HZ我需要发送此信息输出到DUT。

关于从String转换为Long的事情让我感到烦恼,我可以在1.8432 MHz读取然后使用子串来摆脱MHz(通过blah.Substring( 0,blah.Length-4)。可以使用我昨天用于将Amps转换为mA的Decimal.Parse再次使用,记住我想乘以6?

这个问题有意义吗? div class =h2_lin>解决方案

是 - decimal.Parse将其转换为十进制值。

所以将小数乘以6(或者将6000从A转换为mA)并将其投射为长:

  Dim  mA 作为  =  CLng (Math.Truncate( Decimal  .Parse(  1.8432)*  6  *  1000  ))


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?

解决方案

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:

Dim mA As Long = CLng(Math.Truncate(Decimal.Parse("1.8432") * 6 * 1000))


这篇关于是否有一个'容易'转换VB中的指数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆