Print integer as String in Visual Basic
In Visual Basic
I have the code written below, but I have a problem printing it in string format even though it is an integer. I'm trying to save time by not repeating the same thing for over 30 numbers.
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
Problem - displayed:
Display in String
{
line
}
"next line please"
{
line
}
.
.
I want it to display like this: "
Display in String
{
"0"
}
"next line please"
{
"1"
}
.
.
I couldn't find anything like this on SO. Thanks for your help.
+3
source to share
2 answers
Try
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
+2
source to share