|
-
Oct 14th, 2006, 01:06 AM
#1
Thread Starter
Lively Member
[RESOLVED] Mid function
Hi,
I hope somebody in the forum knows VB.6. I am looking for a function that does the samething as Mid function in VB.6. Please see the below sample.
Dim MyString, FirstWord
MyString = "Mid Function Demo" ' Create text string.
FirstWord = Mid(MyString, 1, 3) ' Returns "Mid".
Thanks.
-
Oct 14th, 2006, 02:27 AM
#2
Re: Mid function
What does it do? your example couldn't be more vague
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 14th, 2006, 03:48 AM
#3
Re: Mid function
It's like String.substring, except I think Mid's last argument is the length of the substring, not the end index like in Java.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 14th, 2006, 03:52 AM
#4
Re: Mid function
I don't think so, I found this example:
VB Code:
' Creates text string.
Dim TestString As String = "Mid Function Demo"
' Returns "Mid".
Dim FirstWord As String = Mid(TestString, 1, 3)
' Returns "Demo".
Dim LastWord As String = Mid(TestString, 14, 4)
' Returns "Function Demo".
Dim MidWords As String = Mid(TestString, 5)
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 14th, 2006, 03:54 AM
#5
Re: Mid function
Oh yeah, Mid is 1-based, while String.substring is 0-based. But aside from that, you just proved my point.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 14th, 2006, 04:08 AM
#6
Re: Mid function
 Originally Posted by CornedBee
Oh yeah, Mid is 1-based, while String.substring is 0-based. But aside from that, you just proved my point.
err....I don't know
Why do they call it MID if it has nothing to do with Middle!!
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 14th, 2006, 04:09 AM
#7
Re: Mid function
Well, it has. It takes a part in the middle of the string. As opposed to Beg and End, or whatever they're called, which take a part from the beginning and end of the string, respectively.
Why the designers of VB thought it necessary to have 3 functions is beyond me.
In Java, you do it all with String.substring(), String.length() and a bit of math that a 7-year-old can do.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 14th, 2006, 10:52 AM
#8
Thread Starter
Lively Member
Re: Mid function
MyString = "Mid Function Demo" ' Create text string.
FirstWord = Mid(MyString, 1, 3) ' Returns "Mid".
It returns a string from MyString, starts from postion 1 and 3 characters long.
-
Oct 14th, 2006, 01:05 PM
#9
Re: Mid function
This is how its done in Java
Code:
String MyString, FirstWord ;
MyString = "Mid Function Demo" ;
FirstWord = MyString.substring( 0, 3 ) ;
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 14th, 2006, 01:22 PM
#10
Thread Starter
Lively Member
-
Oct 14th, 2006, 07:48 PM
#11
Re: [RESOLVED] Mid function
And my posts didn't tell you this because ...?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 19th, 2006, 02:43 PM
#12
Lively Member
Re: [RESOLVED] Mid function
it actually does not do what you have talked (above). With the below code, it should start at a position 2 and returns 5 characters.
System.out.println(strFirstBigIn.substring(2,5)+"");
See the out put for more explaination:
Please enter your first BigInt
123456789
345
-
Nov 10th, 2006, 07:21 PM
#13
Re: [RESOLVED] Mid function
 Originally Posted by AlnavPlatinum
it actually does not do what you have talked (above). With the below code, it should start at a position 2 and returns 5 characters.
System.out.println(strFirstBigIn.substring(2,5)+"");
See the out put for more explaination:
Please enter your first BigInt
123456789
345
Im not seeing that anywhere in the thread..?
It goes from position 2 to position 5 which is 3 characters..where is the problem?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|