开发者

How to Insert string in another string in visual basic

开发者 https://www.devze.com 2022-12-31 05:46 出处:网络
the following code shows invalid qualifier when executed Dim strs As String Dim insStr As String Dim strRes As String

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消