https://foro.gambas-es.org/viewtopic.php?f=4&t=8029&p=48340#p48340
-----------------------------------
tincho
Tuesday, 05 May 2020, 21:39

Extendiendo La Clase String
-----------------------------------
Hola a todos.
En base a otro hilo en donde comentamos sobre algunos métodos que le "faltaban" a la clase [b]String[/b] pongo aquí como la extendí.
[code linenumbers=false syntax=gambas]
' Gambas class file
'' This class extends the standard String class in gambas
Export
Create Static
Inherits String
'' This function counts how much times some string apear in other
Public Function StrCount(sWhere As String, sWhich As String) As Integer
  Dim i As Integer
  Dim Cursor As Integer
  Dim Counter As Integer
  i = 1
  Repeat
    Cursor = InStr(sWhere, sWhich, i)
    If Cursor > 0 Then
      Inc Counter
      i = i + Cursor + String.Len(sWhich)
    Endif
  Until InStr(sWhere, sWhich, i) = 0 Or i > String.Len(sWhich)
  Return Counter
End
[/code]
Espero les sea de utilidad.
Saludos.


