הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Tuesday, February 1, 2011 10:34 PM
How can I do it?
All replies (6)
Tuesday, February 1, 2011 10:36 PM ✅Answered | 1 vote
You can use Remove function like this:
Dim str As String = "abcdefghijklm"
str = str.Remove(0, 8)
' See new string
MsgBox(str)
... where 0 (zero) is the start index of string and 8 is the count of chars to remove.**
**
"ijklm" is displayed as first 8 chars (abcdefgh) were removed.
HTH.
Best regards, Saygılarımla, Onur Güzel
[Yazgeliştir Forumları'ndayım.
](http://www.yazgelistir.com/Forumlar/UyeBilgileri.aspx?UyeId=1000107000)Microsoft Haber Grupları Profilim (VB.NET)
Tuesday, February 1, 2011 11:14 PM ✅Answered | 1 vote
Hi Andrew,
Your use of MID
returns the 1st 8 characters.
It does not remove the 1st 8 characters.
I guess you were thinking of? >>
Dim exampleString As String = "this is a string more than 8 characters long"
Dim finalString = Microsoft.VisualBasic.Mid(exampleString, 9) '<< Starts at position 9 the 1st character being counted as position 1
MessageBox.Show(finalString)
Here are both examples together using one Button on a Form.>>
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String = "abcdefghijklm"
str = str.Remove(0, 8)
' See new string
MsgBox(str)
Dim exampleString As String = "this is a string more than 8 characters long"
Dim finalString = Microsoft.VisualBasic.Mid(exampleString, 9) '<< Starts at position 9 the 1st character being counted as position 1
MessageBox.Show(finalString)
End Sub
End Class
Regards, John
Click this link to see how to insert a picture into a forum post.
Wednesday, February 2, 2011 12:30 AM ✅Answered | 1 vote
and I'll add a third way, using Substring:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strText As String = "abcdefghijklm"
strText = strText.Substring(8)
MessageBox.Show(strText)
End Sub
take your pick :)
Tuesday, February 1, 2011 10:44 PM
MsgBox(Mid("this is a string more than 8 characters long", 1, 8))It never hurts to try. In a worst case scenario, you'll learn from it.
Tuesday, February 1, 2011 11:43 PM
Hi Andrew,
Your use of MID
returns the 1st 8 characters.
It does not remove the 1st 8 characters.
I guess you were thinking of? >>
I was actually just saying, "The bait goes here, then that goes in the water."
It never hurts to try. In a worst case scenario, you'll learn from it.
Wednesday, February 9, 2011 9:49 AM
Hi Xakepa,
Any update?
How about your problem now? If you need some help, please feel free to let us know. If it works, you can share your solutions & experience here, it will be very beneficial for other community members who have similar questions. Thanks.
Best Regards,
Mike Feng [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.