我正在努力解决这个问题:
我有这个:
Dim nam as String = "my name is John Scott"
Dim fn As String = "James"
我想将其替换为:
nam = "my name is " & fn & " Scott"
我试过这个:
nam = nam.Replace("John", """" & fn & """")
但是这给了我:
nam = "my name is "" & fn & "" Scott".
有人可以帮我解决这个问题吗?
答案 0 :(得分:0)
方法1:
Module Module1
Sub Main()
Dim nam As String = "my name is John Scott"
Dim fn As String = "James"
nam = "my name is """ & fn & """ Scott"
MsgBox(nam)
End Sub
End Module
方法2:
Module Module1
Sub Main()
Dim nam As String = "my name is John Scott"
Dim fn As String = "James"
fn = """" & fn & """"
nam = "my name is " & fn & " Scott"
MsgBox(nam)
End Sub
End Module
答案 1 :(得分:0)
或使用此方法
Dim fn As String = "James" CHR(34) &