Advertisement
2_2002-2004 String Manipulation #117974

getstr

If an alphanumeric string is provided in the form 123,33,44,556 , my function seperates the numbers seperated by any character in this case a (,)comma so we get num1=123 , num2 = 33 , num3=44 and so on.The function uses an array to store these numbers.DO mail me on how well this code works.

AI

Résumé par IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Code source
original-source
Sub getstr()
saved = "123,45,6789,99" 'save contents of string to a variable
i = 1      ' Counter variable for array
       'location identifiers for comma
res = 1
def = 1
'loop to seperate sub-string numbers from string
Do While res > 0 ' loop until no comma is found
res = InStr(def, saved, ",")
If InStr(def + 1, saved, ",") = 0 Then
counted = Len(saved)
Else
counted = InStr(def + 1, saved, ",") - def
End If
arr(i) = Mid(saved, def, counted)
label1.Caption = Str(res)
def = res + 1
i = i + 1
Loop
label1.Caption = "The numbers are "
Do While i > 0
label1.Caption = label1.Caption + " " + arr(i)
i = i - 1
Loop
' The numbers are stored in Array { arr(i) }
End Sub
Commentaires originaux (3)
Récupéré via Wayback Machine