OptiPlex Posted October 28, 2004 Share Posted October 28, 2004 How would I read a part of a line, such as the contents of string var "ab" from the 5th letter to the end Link to comment Share on other sites More sharing options...
0 RuudJacobs.NET Posted October 28, 2004 Share Posted October 28, 2004 Dim yournewstring, ab As String ab = "Hello World!" yournewstring = Mid(ab,5,Len(ab)) would put out this: "o World!" Mid syntax = Mid(string, start as int, length as int) so if you do Mid(ab,5,Len(ab)) it takes a part from ab which starts at the 5th character, and ends at the last character (= Len(ab) ) Good luck. Buy some books on VB(.NET) Link to comment Share on other sites More sharing options...
0 OptiPlex Posted October 28, 2004 Author Share Posted October 28, 2004 Books! Only if it was cheap! Link to comment Share on other sites More sharing options...
0 Winston Posted October 28, 2004 Share Posted October 28, 2004 Since you're programming in .NET i'd advise you to make use of the methods/functions provided by the base class library, at least when you move over to C# for example you wuld be fairly confident with using it. Mid is a legacy function used in the later versions of VB (VB6 and older versions). Although i don't really think there's much of an issue of using legacy functions, most .NET enthusiasts encourage using the functions provided by the framework. So in this case i'd advise using the SubString function instead. Check out this link for VB6 String Manipulation Equivalents in .NET: http://www.planet-source-code.com/vb/scrip...d=169&lngWId=10 If any experienced .NET Developer reads this, if you use legacy functions in the Microsoft.VisualBasic namespace, wouldn't that force that to be imported, and like if you're using just say two functions from this namespace, wouldn't that be sort of inefficient? Just wondering. Link to comment Share on other sites More sharing options...
0 Sn1p3t Posted October 29, 2004 Share Posted October 29, 2004 Dim firstString, myNewString as String firstString = "Hello world!" myNewString = firstString.SubString(4) Do not use Mid. It's a legacy VB6 function that is only there for porting issues. Use .NET stanard mehods, such as Substring. That makes moving to another language much easier. Link to comment Share on other sites More sharing options...
0 Sn1p3t Posted October 29, 2004 Share Posted October 29, 2004 If any experienced .NET Developer reads this, if you use legacy functions in the Microsoft.VisualBasic namespace, wouldn't that force that to be imported, and like if you're using just say two functions from this namespace, wouldn't that be sort of inefficient? Just wondering. 584824235[/snapback] I'm not extremely experienced, but I don't believe importing DLL's makes the application any less efficient. I'm probably wrong though. :p Link to comment Share on other sites More sharing options...
Question
OptiPlex
How would I read a part of a line, such as the contents of string var "ab" from the 5th letter to the end
Link to comment
Share on other sites
5 answers to this question
Recommended Posts