Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18013
Number of posts: 55386

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to use the (left,right,middle) functions in visual basic 6 Posted by mostafakamar on 8 Feb 2005 at 2:35 PM
I wonder if anybody kindly can help me to know how to use the (left,middle,right) function in visual basic 6.0 . basicly i need a function to deal with every charecter in a word on its own, i guess that is the right function, but i do not have its syntax. so if you can help or if u have another easier function for the same operation i will be very greatful. thanks in advance
Report
Re: How to use the (left,right,middle) functions in visual basic 6 Posted by the walrus on 8 Feb 2005 at 2:58 PM
This message was edited by the walrus at 2005-2-8 14:59:56

: I wonder if anybody kindly can help me to know how to use the (left,middle,right) function in visual basic 6.0 . basicly i need a function to deal with every charecter in a word on its own, i guess that is the right function, but i do not have its syntax. so if you can help or if u have another easier function for the same operation i will be very greatful. thanks in advance
:

you probably want to use Mid(String, Position, Length). here's an example:

Dim xStr as String

xStr = Mid$("This is a string", 6, 8)
MsgBox xStr


the output will be "is a str", because it takes the section of the string starting at the 6th character and ending at the 14th (6 + 8) character.

here's an example for processing each character of a string:

Dim xStr as String, yStr as String, i as Long

xStr = "This is a string"

For i = 1 to Len(xStr)
     yStr = yStr & Mid(xStr, i, 1) & " "
Next

MsgBox yStr


as you see, this adds a space between each character in xStr and saves it in yStr, so for processing each character in a string, mid is the way to go, but just so you'll know here's how to use Left and Right.

Dim xStr as String

xStr = "This is a string"
MsgBox Left(xStr, 8)
MsgBox Right(xStr, 8)



Report
Re: How to use the (left,right,middle) functions in visual basic 6 Posted by mostafakamar on 8 Feb 2005 at 3:29 PM
I will check my self and thank you for helping me.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.