4

在 Visual Basic 中,

我编写了以下代码,但我在以字符串格式打印它时遇到问题,尽管它是整数类型。我试图通过不对 30 多个数字重复相同的事情来节省时间。

Dim line As Integer
line = 0

Sub DisplayModule(page As Integer, line As Integer)
maxline = 100    
For line = 0 To maxline
Print #page, Spc(6); "Display in String"
Print #page, Spc(8); "{"
Print #page, Spc(10); """line"""
Print #page, Spc(8); "}"
Print #page, Spc(8); "next"
Next
End Sub

问题 - 它显示:

Display in String
{
 line
}
"next line please"
{
 line
}
.
.

我希望它用 "" 显示如下:

Display in String
{
 "0"
}
"next line please"
{
 "1"
}
.
.

我在 SO 上找不到类似的东西。谢谢你的帮助。

4

2 回答 2

5

尝试这个

Print #page, Spc(10); chr(34) & line & chr(34)
于 2013-02-19T13:44:06.797 回答
2

尝试

Dim line As Integer
line = 0

Sub DisplayModule(page As Integer, line As Integer)
   maxline = 100    
   For line = 0 To maxline
      Print #page, Spc(6); "Display in String"
      Print #page, Spc(8); "{"
      Print #page, Spc(10); """" & line & """"
      Print #page, Spc(8); "}" 
      Print #page, Spc(8); "next"
   Next
End Sub
于 2013-02-19T13:44:54.797 回答