Visual Basic - algoritmer - Strings
downx.gif (830 bytes)Fielddownx.gif (830 bytes)Numeric stringdownx.gif (830 bytes)Replace

Strings - Field

RightSet
FS : FieldString
returns S rightset in a field of F spaces
Private Function FS(F As Integer, S As String) As String
  Dim T As String
  T = Space(F)
  RSet T = S
  FS = T
End Function
 
FN : FieldNumber
returns N rightset in a field of F spaces
Private Function FN(F As Integer, N As Single) As String
  FN = FS(F, Format(N, "fixed"))
End Function
 
Ex:
i = 5 : snPrin = 2550,45
sAdd = FS(5, Str(i)) & FN(10, snPrin)
123451234567890
    5   2550,45

Strings - Numeric string

ByteToBinary (num)
Dim bin As String * 8, p As Integer
bin = "00000000"
p = 8
Do While num > 0 And p > 0
  If num Mod 2 Then Mid$(bin, p) = "1"
  num = num \ 2
  p = p - 1
Loop

Strings - Replace

Replace length% chars from start% in text$ with txt$
Function replace (text$, start%, length%, txt$) As String
  Dim L%, Tail%

  L% = Len(text$) + 1
  Tail% = L% - start%

  If start% < 1 Then start% = 1
  If start% > L% Then start% = L%
  If length% < 0 Then length% = 0
  If length% > Tail% Then length% = Tail%

  replace = Left$(text$, start% - 1) & txt$ & Right$(text$, Tail% - length%)
End Function
  
'Ex:
label1 = replace(CStr(text1), Val(text2), Val(text3), CStr(text4))