【问题标题】:Translate this simple C code to VBA将这个简单的 C 代码翻译成 VBA
【发布时间】:2015-08-03 17:50:41
【问题描述】:

我希望打印一个包含字符串和浮点数的输出。 例如,我使用 D = 质量/体积计算了一个盒子的密度。我现在想生成一个输出说“你的盒子的密度是 **** kg/cubicM”

这就是在 C 中实现的方式

printf("The density of your box is %d\n", D);

如何在 VBA 上实现这一点?

【问题讨论】:

  • 我可以给你答案。这很简单,但我想知道您是否尝试过自己找到它?
  • 我建议阅读 MsgboxDebug.Print&(字符串连接)

标签: c vba excel output translate


【解决方案1】:

使用MsgBox 语句和Format 函数来格式化值:

MsgBox "The density of your box is " & Format(D, "0.00")

【讨论】:

    【解决方案2】:
    Dim boxDensity as String
    boxDensity =  "The density of your box is : " & D & "kg/cubicM"
    

    你可以随意使用变量

    【讨论】:

      猜你喜欢
      • 2011-12-05
      • 1970-01-01
      • 1970-01-01
      • 2021-07-25
      • 2020-02-08
      • 1970-01-01
      • 2011-09-05
      • 1970-01-01
      • 2016-08-04
      相关资源
      最近更新 更多