Mid Function, Mid Statement

Vráti určenú časť reťazca (funkcia Mid) alebo nahradí časť reťazca iným reťazcom (príkaz Mid).

Syntax:


Mid (Text As String, Začiatok As Long [, Dĺžka As Long]) alebo Mid (Text As String, Začiatok As Long , Dĺžka As Long, Text As String)

Return value:

Typu String (len v prípade funkcie)

Parameters:

Text: Reťazec, ktorý chcete upraviť.

Start: Numeric expression that indicates the character position within the string where the string portion that you want to replace or to return begins. The minimum allowed value is 1. The maximum allowed value is 2,147,483,648.

Length: Numeric expression that returns the number of characters that you want to replace or return. The maximum allowed value is 2,147,483,648.

Ak je vo funkcii Mid vynechaný parameter Dĺžka, vrátia sa všetky znaky od počiatočnej pozície do konca reťazca.

Ak je v príkaze Mid parameter Dĺžka menší než dĺžka textu, ktorý chcete nahradiť, text bude skrátený na určenú dĺžku.

Text: Reťazec, ktorým chcete nahradiť určenú časť reťazca (príkaz Mid).

Error codes:

5 Neplatné volanie procedúry

Example:


Sub ExampleUSDate
Dim sInput As String
Dim sUS_date As String
    sInput = InputBox("Zadajte, prosím, dátum v medzinárodnom formáte 'YYYY-MM-DD'")
    sUS_date = Mid(sInput, 6, 2)
    sUS_date = sUS_date & "/"
    sUS_date = sUS_date & Right(sInput, 2)
    sUS_date = sUS_date & "/"
    sUS_date = sUS_date & Left(sInput, 4)
    MsgBox sUS_date
End Sub

Please support us!