Strings.Mid Yöntem
Tanım
Belirtilen dizeden karakterler içeren bir dize döndürür.Returns a string that contains characters from a specified string.
Aşırı Yüklemeler
| Mid(String, Int32) |
Dizedeki belirli bir konumdan başlayan tüm karakterleri içeren bir dize döndürür.Returns a string that contains all the characters starting from a specified position in a string. |
| Mid(String, Int32, Int32) |
Dizedeki belirli bir konumdan başlayarak belirtilen sayıda karakteri içeren bir dize döndürür.Returns a string that contains a specified number of characters starting from a specified position in a string. |
Mid(String, Int32)
Dizedeki belirli bir konumdan başlayan tüm karakterleri içeren bir dize döndürür.Returns a string that contains all the characters starting from a specified position in a string.
public:
static System::String ^ Mid(System::String ^ str, int Start);
public static string? Mid (string? str, int Start);
public static string Mid (string str, int Start);
static member Mid : string * int -> string
Public Function Mid (str As String, Start As Integer) As String
Parametreler
- str
- String
Gereklidir.Required. String karakterlerin döndürüldüğü ifade.String expression from which characters are returned.
- Start
- Int32
Gereklidir.Required. Integer ifadesini.Integer expression. Döndürülecek karakterlerin başlangıç konumu.Starting position of the characters to return. , Start İçindeki karakter sayısından büyükse str , Mid işlev sıfır uzunluklu bir dize ("") döndürür.If Start is greater than the number of characters in str, the Mid function returns a zero-length string (""). Start tek tabanlıdır.Start is one-based.
Döndürülenler
Dizedeki belirtilen konumdan başlayan tüm karakterlerden oluşan bir dize.A string that consists of all the characters starting from the specified position in the string.
Özel durumlar
Start<= 0 veya Length < 0.Start <= 0 or Length < 0.
Örnekler
Bu örnekteki son satır, Mid bir dizeden beşinci ve sonraki karakterleri döndürmek için işlevinin bu aşırı yüklemesini kullanır.The last line in this example uses this overload of the Mid function to return the fifth and subsequent characters from a string.
' 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)
Açıklamalar
İçindeki karakter sayısını öğrenmek için str Len işlevini kullanın.To determine the number of characters in str, use the Len function.
Visual Basic bir Mid işleve ve ifadeye sahiptir Mid .Visual Basic has a Mid function and a Mid statement. Bu öğeler her ikisi de bir dizedeki belirtilen sayıda karakter üzerinde çalışır, ancak işlev, Mid ifadenin karakterleri değiştirdiği sırada karakterleri döndürür Mid .These elements both operate on a specified number of characters in a string, but the Mid function returns the characters while the Mid statement replaces the characters. Daha fazla bilgi için bkz. MIN açıklaması.For more information, see Mid Statement.
Not
MidBVisual Basic önceki sürümlerindeki işlev, karakter yerine bayt cinsinden bir dize döndürür.The MidB function in previous versions of Visual Basic returns a string in bytes rather than characters. Esas olarak çift baytlı karakter kümesi (DBCS) uygulamalarında dize dönüştürmek için kullanılır.It is used primarily for converting strings in double-byte character set (DBCS) applications. Tüm Visual Basic dizeleri Unicode ve MidB artık desteklenmiyor.All Visual Basic strings are in Unicode, and MidB is no longer supported.
Ayrıca bkz.
- Left(String, Int32)
- Len
- Trim(String)
- LTrim(String)
- RTrim(String)
- Right(String, Int32)
- ArgumentException
- Dize Düzenleme ÖzetiString Manipulation Summary
- Visual Basic'de DizelerStrings in Visual Basic
- Visual Basic'de Dizelere GirişIntroduction to Strings in Visual Basic
- Mid DeyimiMid Statement
Şunlara uygulanır
Mid(String, Int32, Int32)
Dizedeki belirli bir konumdan başlayarak belirtilen sayıda karakteri içeren bir dize döndürür.Returns a string that contains a specified number of characters starting from a specified position in a string.
public:
static System::String ^ Mid(System::String ^ str, int Start, int Length);
public static string Mid (string? str, int Start, int Length);
public static string Mid (string str, int Start, int Length);
static member Mid : string * int * int -> string
Public Function Mid (str As String, Start As Integer, Length As Integer) As String
Parametreler
- str
- String
Gereklidir.Required. String karakterlerin döndürüldüğü ifade.String expression from which characters are returned.
- Start
- Int32
Gereklidir.Required. Integer ifadesini.Integer expression. Döndürülecek karakterlerin başlangıç konumu.Starting position of the characters to return. , Start İçindeki karakter sayısından büyükse str , Mid işlev sıfır uzunluklu bir dize ("") döndürür.If Start is greater than the number of characters in str, the Mid function returns a zero-length string (""). Start bir tabanlıdır.Start is one based.
- Length
- Int32
İsteğe bağlı.Optional. Integer ifadesini.Integer expression. Döndürülecek karakter sayısı.Number of characters to return. Atlanırsa veya Length metinde (konumdaki karakter dahil) daha az karakter varsa Start , başlangıç konumundan dizenin sonuna kadar olan tüm karakterler döndürülür.If omitted or if there are fewer than Length characters in the text (including the character at position Start), all characters from the start position to the end of the string are returned.
Döndürülenler
Dizedeki belirtilen konumdan başlayarak belirtilen sayıda karakterden oluşan bir dize.A string that consists of the specified number of characters starting from the specified position in the string.
Özel durumlar
Start<= 0 veya Length < 0.Start <= 0 or Length < 0.
Örnekler
MidBu örnekteki ilk iki işlev, belirli konumlardan başlayarak bir dizeden belirtilen sayıda karakteri döndürür.The first two Mid functions in this example return the specified number of characters from a string, starting from the given positions. (Son işlev Mid(String, Int32) aşırı yüklemeyi gösterir ve yalnızca dize ayıklama için başlangıç noktasını belirtir.)(The last function illustrates the Mid(String, Int32) overload and only specifies the starting point for the string extraction.)
' 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)
Açıklamalar
İçindeki karakter sayısını öğrenmek için str Len işlevini kullanın.To determine the number of characters in str, use the Len function.
Visual Basic bir Mid işleve ve ifadeye sahiptir Mid .Visual Basic has a Mid function and a Mid statement. Bu öğeler her ikisi de bir dizedeki belirtilen sayıda karakter üzerinde çalışır, ancak işlev, Mid ifadenin karakterleri değiştirdiği sırada karakterleri döndürür Mid .These elements both operate on a specified number of characters in a string, but the Mid function returns the characters while the Mid statement replaces the characters. Daha fazla bilgi için bkz. MIN açıklaması.For more information, see Mid Statement.
Not
MidBVisual Basic önceki sürümlerindeki işlev, karakter yerine bayt cinsinden bir dize döndürür.The MidB function in previous versions of Visual Basic returns a string in bytes rather than characters. Esas olarak çift baytlı karakter kümesi (DBCS) uygulamalarında dize dönüştürmek için kullanılır.It is used primarily for converting strings in double-byte character set (DBCS) applications. Tüm Visual Basic dizeleri Unicode ve MidB artık desteklenmiyor.All Visual Basic strings are in Unicode, and MidB is no longer supported.
Ayrıca bkz.
- Left(String, Int32)
- Len
- Trim(String)
- LTrim(String)
- RTrim(String)
- Right(String, Int32)
- ArgumentException
- Dize Düzenleme ÖzetiString Manipulation Summary
- Visual Basic'de DizelerStrings in Visual Basic
- Visual Basic'de Dizelere GirişIntroduction to Strings in Visual Basic
- Mid DeyimiMid Statement