[Off] detectar texto ... vb. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (
https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: [Off] detectar texto ... vb. (
/showthread.php?tid=463212)
detectar texto ... vb. -
OTACON - 10.09.2013
Buenas a todos, me puedes ayudar con una cosita de visualbasic, como podria hacer para verificar si en un label box se escribe una palabra y la cantidad de veces?..
Si me pueden ayudar se los agradezco.
desde ya muchas gracias
Respuesta: detectar texto ... vb. -
TheChaoz - 11.09.2013
Aca te dejo una funcion que hace lo que pides, la hice algo generica aun que podria mejorarse. Cualquier cosa me avisas:
Код:
Public Function CountReps(ByVal text As String, ByVal word As String, Optional ByVal separator As String = " ", Optional ByVal sensitive As Boolean = False) As Integer
Dim count As Integer, _
Items() As String
If (sensitive = False) Then
word = word.ToLower()
text = text.ToLower()
separator = separator.ToLower
End If
Items = text.Split(separator)
For Each item As String In Items
If item = word Then
count += 1
End If
Next
Return count
End Function