What is difference between Mid function and Mid Statement ?

 Posted by Bhakti on 12/23/2009 | Category: VB.NET Interview questions | Views: 9488
Answer:

Mid function returns the characters while the Mid statement replaces the characters.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Raja on: 12/23/2009
Hey Bhakti,

Congratulations on winning the prize. Can you please give an example of Mid function and Mid statement?

Thanks
Posted by: Poster on: 12/23/2009
For equivalent Mid statement in C#, you can see http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/37d137f8-f8c9-4971-ab94-d3e7143d44c5

But still seems to be confusion between the Mid function and statement. Bhakti can you describe please.


Posted by: Bhakti on: 12/23/2009
Raja, Thanks a lot for the wishes.
Poster, thanks for adding reference for C#.

To make the things little more clearer i am adding example below.

    Sub Main()

Dim testString = "TestingStringHere"
Mid(testString, 5) = "..Bore.." ' it is Mid statement
Console.WriteLine(testString) ' returns Test..Bore..gHere - its replacing string

Dim midstring As String = "TestingStringHere"
midstring = Mid(midstring, 8, 6) ' it is Mid function
Console.WriteLine(midstring) ' returns string - its just extracting string
End Sub


Hope this can help to understand "MID" better...!

Let me know in case of any concerns with the same.

Regards,
Bhakti Shah

Login to post response