How to split a string the hard way (VB6)
-
It took me about 20 minutes to work out what the heck this For/Next loop was doing. The programmer must not have heard of .Split. It takes a key from an INI file (vkeys) and if it is formatted as such:
SERVICES = Service1, Service2, Service3, Service4 ...
it puts the list of services into an array for later use..If vkeys(lval, 0) = "services" Or vkeys(lval, 0) = "SERVICES" Then
totallength = Len(vkeys(lval, 1))
For searchstring = 1 To totallength
tempcounter2 = tempcounter2 + 1
If Mid(vkeys(lval, 1), searchstring, 1) = "," Then
servicecount(X) = servicecount(X) + 1
nodeservices(X, servicecount(X)) = Mid(vkeys(lval, 1), _
tempcounter1, tempcounter2 - 1)
If Right(nodeservices(X, servicecount(X)), 1) = "," Then
' This strips the comma of the end of the string.
nodeservices(X, servicecount(X)) = _
Left(nodeservices(X, servicecount(X)),_
(Len(nodeservices(X, servicecount(X))) - 1))
End If'Sets start of service name within string tempcounter1 = searchstring + 1 tempcounter2 = 1 End If If searchstring = totallength Then nodeservices(X, (servicecount(X) + 1)) = Mid(vkeys(lval, 1),\_ tempcounter1, tempcounter2 - 1) ' Gets the last service. End If Next searchstring servicecount(X) = servicecount(X) + 1 tempcounter2 = 1
End If
-
It took me about 20 minutes to work out what the heck this For/Next loop was doing. The programmer must not have heard of .Split. It takes a key from an INI file (vkeys) and if it is formatted as such:
SERVICES = Service1, Service2, Service3, Service4 ...
it puts the list of services into an array for later use..If vkeys(lval, 0) = "services" Or vkeys(lval, 0) = "SERVICES" Then
totallength = Len(vkeys(lval, 1))
For searchstring = 1 To totallength
tempcounter2 = tempcounter2 + 1
If Mid(vkeys(lval, 1), searchstring, 1) = "," Then
servicecount(X) = servicecount(X) + 1
nodeservices(X, servicecount(X)) = Mid(vkeys(lval, 1), _
tempcounter1, tempcounter2 - 1)
If Right(nodeservices(X, servicecount(X)), 1) = "," Then
' This strips the comma of the end of the string.
nodeservices(X, servicecount(X)) = _
Left(nodeservices(X, servicecount(X)),_
(Len(nodeservices(X, servicecount(X))) - 1))
End If'Sets start of service name within string tempcounter1 = searchstring + 1 tempcounter2 = 1 End If If searchstring = totallength Then nodeservices(X, (servicecount(X) + 1)) = Mid(vkeys(lval, 1),\_ tempcounter1, tempcounter2 - 1) ' Gets the last service. End If Next searchstring servicecount(X) = servicecount(X) + 1 tempcounter2 = 1
End If
-
It's a horror right from the first line
If vkeys(lval, 0) = "services" Or vkeys(lval, 0) = "SERVICES" Then
...what about "Services"
-
Release 1.01: Added support for "Services".
Agh! Reality! My Archnemesis![^]
| FoldWithUs! | sighist | µLaunch - program launcher for server core and hyper-v server.Bug report: it fails with "serviceS". :laugh:
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
-
Bug report: it fails with "serviceS". :laugh:
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
OriginalGriff wrote:
Bug report: it fails with "serviceS".
Dear Mr./Ms. User, We are currently offering support for "services", "Services", "SERVICES" (based on user skill - does not know about text formatting rules, knows about text formatting rules, does not know about CAPS LOCK key) and we plan to support "sERVICES" (for users who know formatting rules but forgot about CAPS LOCK key) in future releases. As far as we see, "serviceS" is an anomaly and it should not be considered a bug. Yours trully, Programming Team Leader.
I have no smart signature yet...
-
Bug report: it fails with "serviceS". :laugh:
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
Development team answer: This is not a bug. All key values must be uppercase. We are simplifying the application so services and Services are no more supported, avoiding further errors. In fact, the check is now: If len(vkeys[lval, 0]) = 8 and Mid(lvkeys[lval, 0], 0, 1) = "S" and Mid(lvkeys[lval, 0], 1, 1) = "E" ... and so on. :laugh: (Note, I started to write this at the same time of the last post... I think our development team is having problems of communication... who the hell tought we must support other keywords?? :doh: ).