Click here to Skip to main content
15,887,596 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: How to convert minutes into milliseconds... Pin
PIEBALDconsult19-Mar-10 9:54
mvePIEBALDconsult19-Mar-10 9:54 
GeneralRe: How to convert minutes into milliseconds... Pin
Andrew Rissing19-Mar-10 10:38
Andrew Rissing19-Mar-10 10:38 
GeneralRe: How to convert minutes into milliseconds... Pin
Luc Pattyn19-Mar-10 11:09
sitebuilderLuc Pattyn19-Mar-10 11:09 
GeneralRe: How to convert minutes into milliseconds... Pin
Andrew Rissing19-Mar-10 11:40
Andrew Rissing19-Mar-10 11:40 
GeneralBrowser Support Check Pin
ghaberek9-Mar-10 10:21
ghaberek9-Mar-10 10:21 
JokeRe: Browser Support Check Pin
chevu9-Mar-10 18:12
chevu9-Mar-10 18:12 
GeneralRe: Browser Support Check Pin
Chris Meech10-Mar-10 6:10
Chris Meech10-Mar-10 6:10 
GeneralHow to split a string the hard way (VB6) Pin
AaronM_NZ7-Mar-10 12:58
AaronM_NZ7-Mar-10 12:58 
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..


VB
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

GeneralRe: How to split a string the hard way (VB6) Pin
GibbleCH8-Mar-10 6:14
GibbleCH8-Mar-10 6:14 
GeneralRe: How to split a string the hard way (VB6) Pin
peterchen9-Mar-10 8:57
peterchen9-Mar-10 8:57 
GeneralRe: How to split a string the hard way (VB6) Pin
OriginalGriff9-Mar-10 9:25
mveOriginalGriff9-Mar-10 9:25 
GeneralRe: How to split a string the hard way (VB6) Pin
Stanciu Vlad9-Mar-10 10:30
Stanciu Vlad9-Mar-10 10:30 
GeneralRe: How to split a string the hard way (VB6) Pin
Paulo Zemek9-Mar-10 10:35
mvaPaulo Zemek9-Mar-10 10:35 
GeneralEver heard of casting? Pin
ArchimaX3-Mar-10 0:49
ArchimaX3-Mar-10 0:49 
GeneralRe: Ever heard of casting? [modified] Pin
OriginalGriff3-Mar-10 1:11
mveOriginalGriff3-Mar-10 1:11 
AnswerMessage Removed Pin
3-Mar-10 1:24
chevu3-Mar-10 1:24 
GeneralRe: Ever heard of casting? Pin
johannesnestler3-Mar-10 3:52
johannesnestler3-Mar-10 3:52 
GeneralRe: Ever heard of casting? [modified] Pin
chevu3-Mar-10 16:25
chevu3-Mar-10 16:25 
GeneralRe: Ever heard of casting? Pin
Luc Pattyn3-Mar-10 16:41
sitebuilderLuc Pattyn3-Mar-10 16:41 
GeneralRe: Ever heard of casting? Pin
johannesnestler4-Mar-10 22:54
johannesnestler4-Mar-10 22:54 
GeneralRe: Ever heard of casting? Pin
Luc Pattyn3-Mar-10 4:39
sitebuilderLuc Pattyn3-Mar-10 4:39 
GeneralRe: Ever heard of casting? Pin
harold aptroot3-Mar-10 7:11
harold aptroot3-Mar-10 7:11 
JokeRe: Ever heard of casting? Pin
Stanciu Vlad3-Mar-10 3:25
Stanciu Vlad3-Mar-10 3:25 
JokeRe: Ever heard of casting? Pin
johannesnestler3-Mar-10 4:53
johannesnestler3-Mar-10 4:53 
GeneralRe: Ever heard of casting? Pin
johannesnestler3-Mar-10 3:48
johannesnestler3-Mar-10 3:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.