views:

40

answers:

2

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 = strs.Insert(insStr) 

Thanks in advance

+2  A: 

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"
Oded
A: 

You forgot to say where in the string it should be inserted.

strRes = strs.Insert(strs.Length \ 2, insStr)
ho1