Mid$
sResult = Mid$ ( sSource AS String , iStart AS Integer [ , iLength AS Integer ] ) AS String
sResult = Mid ( sSource AS String , iStart AS Integer [ , iLength AS Integer ] ) AS String
Retorna uma
String, que é a parte da
String sSource, que começa na posição
iStart e tem o comprimento
iLength.
Se
iLength não for especificado, tudo a partir da posição
iStart até o final é retornado.
Se
iLength for negativo, tudo a partir da posição
Start exceto os (-
iLength ) últimos caracteres é retornado.
Mid$
é otimizado para que não haja duplicação da string quando gerar o resultado.
Exemplos
PRINT Mid$("Gambas", 3, 2)
mb
PRINT Mid$("Gambas", 4)
bas
PRINT Mid$("Gambas", 2, -1)
amba
Mid$ ( Variable AS String , Start AS Integer [ , Length AS Integer ] ) = Expression
Mid ( Variable AS String , Start AS Integer [ , Length AS Integer ] ) = Expression
Esta sintaxe permite modificar o conteúdo de uma variável string
É apenas melhoria sintática, ou seja, o compilador a substitui internamente:
Mid$(Variable, Start, Length) = Expression
No seguinte código:
Variable = Left$(Variable, Start - 1) & Expression & Mid$(Variable, Start + Length)
Veja também