How to Insert string in another string in visual basic
the following code shows invalid qualifier when executed
Dim strs As String
Dim insStr As String
Dim strRes As String
strs = "This is VB.NET Test"
insStr = "Insert"
strRes = 开发者_如何学JAVAstrs.Insert(insStr)
If you look at the signature of String.Insert
, you can see it takes two parameters. You have only supplied one. You need to specify what place to insert the second string into:
Dim strs As String
Dim insStr As String
Dim strRes As String
Dim index As Integer = 0
strs = "This is VB.NET Test"
insStr = "Insert"
strRes = strs.Insert(index, insStr)
'strRes = "InsertThis is VB.NET Test"
You forgot to say where in the string it should be inserted.
strRes = strs.Insert(strs.Length \ 2, insStr)
精彩评论