Author | Message | Time |
---|---|---|
InSeCuRe | [EDIT] RESOLVED! | May 16, 2004, 5:46 AM |
DarkMinion | IMO, it's bad to store flags as a string... | May 16, 2004, 5:51 AM |
InSeCuRe | [quote author=DarkMinion link=board=17;threadid=6825;start=0#msg60359 date=1084686688] IMO, it's bad to store flags as a string... [/quote] imo? and what do you sugest? | May 16, 2004, 5:54 AM |
Eibro | [quote author=Insecure link=board=17;threadid=6825;start=0#msg60361 date=1084686867] [quote author=DarkMinion link=board=17;threadid=6825;start=0#msg60359 date=1084686688] IMO, it's bad to store flags as a string... [/quote] imo? and what do you sugest? [/quote]A bitfield is best. I'm not sure how you'd implement such in VB, but it's something like this in C/C++.[code]union Flags { DWORD dwFlags; struct { unsigned flag1 : 1; // name this whatever unsigned flag2 : 1; }; }; // ... Flag myFlags; myFlags.flag1 = TRUE; if ( myFlags.flag2 ) // flag2 is set // dosomething [/code] | May 16, 2004, 6:14 AM |
InSeCuRe | I need something in vb:(! | May 16, 2004, 6:17 AM |
DarkMinion | Eibro's way is the hard way btw, if you ever switch to C++ | May 16, 2004, 8:07 AM |
InSeCuRe | RESOLVED:)! | May 16, 2004, 8:11 AM |
DarkMinion | This is what I do in C++...if you get proficient enough with VB you might be able to port it This struct will store a user: [code] struct User{ char szMask[32]; unsigned long dwFlags; }; [/code] Then using my list class I will construct a list of users, which will be my database: [code] List<User *> Database; [/code] I use these functions to manipulate flags: [code] bool CheckFlag(unsigned long dwMask, char bFlag) { if(bFlag < 'A' || bFlag > 'Z') return false; return !!(dwMask & (1 << (bFlag - 'A'))); } int GetAllFlags(unsigned long dwMask, char *lpszBuffer) { int iCount = 0; for(int i = 'A'; i <= 'Z'; i++){ if(CheckFlag(dwMask, (char)i)){ lpszBuffer[iCount++] = i; } } lpszBuffer[iCount] = 0; return iCount; } void SetFlag(unsigned long *dwMask, char bFlag) { if(bFlag < 'A' || bFlag > 'Z') return; *dwMask |= (1 << (bFlag - 'A')); } void RemoveFlag(unsigned long *dwMask, char bFlag) { if(bFlag < 'A' || bFlag > 'Z') return; *dwMask &= ~(1 << (bFlag - 'A')); } [/code] I add items to my db like so: [code] User *p = new User; strcpy(p->szMask, "whatever"); SetFlag(p->dwFlags, 'A'); //or whatever Database.Add(p); [/code] You *can* port this to VB if you know what you're doing, I'll leave that up to you. | May 16, 2004, 8:12 AM |
Myndfyr | [quote author=Insecure link=board=17;threadid=6825;start=0#msg60370 date=1084695093] RESOLVED:)! [/quote] How about leaving your question up so that future people might benefit from your wisdom? | May 16, 2004, 10:11 AM |
CrAz3D | [quote author=Myndfyre link=board=17;threadid=6825;start=0#msg60374 date=1084702283] [quote author=Insecure link=board=17;threadid=6825;start=0#msg60370 date=1084695093] RESOLVED:)! [/quote] How about leaving your question up so that future people might benefit from your wisdom? [/quote] Not to forget the answer | May 16, 2004, 2:57 PM |
InSeCuRe | ok;) | May 16, 2004, 4:14 PM |
ChR0NiC | [quote author=Insecure link=board=17;threadid=6825;start=0#msg60358 date=1084686415] [EDIT] RESOLVED! [/quote] I remembering doing this and as a result, I got a lecture and such from the Admins. [red]*awaits Admin lecture*[/red] | May 16, 2004, 4:25 PM |
Spht | [quote author=Insecure link=board=17;threadid=6825;start=0#msg60358 date=1084686415] [EDIT] RESOLVED! [/quote] Don't do that. | May 16, 2004, 4:44 PM |
BinaryzL | Called a user type in vb [code]Public UserDB() As db ' Dynamic Array ' Private Type db strUsername As String strFlags as String ' Or whatever you want ' End Type Ex. UserDB(intIndex).strUsername = "Binary[zL]" [/code] | May 16, 2004, 6:45 PM |