Visual basic help

Discussion in 'OT Technology' started by numnuts, Dec 22, 2007.

  1. numnuts

    numnuts New Member

    Joined:
    Apr 26, 2007
    Messages:
    2,508
    Likes Received:
    0
    Location:
    Third Coast
    How do you set the limit(storage/memory) of a string in visual basic ?
     
  2. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    strings are limited to 2^32
    text box captions are limited to 64K


    What are you trying to limit? How are you storing the string? If you want to impose limitations on string length, do that programatically when you "sanitize" the input.
     
  3. Fifafever

    Fifafever OT Supporter

    Joined:
    Jul 22, 2006
    Messages:
    5,603
    Likes Received:
    14
    Location:
    San Diego, Canada
    I remember that in vb6 it was: Dim text As String * length. I doubt this is what you're looking for since this just limits the amount of characters.
     
  4. numnuts

    numnuts New Member

    Joined:
    Apr 26, 2007
    Messages:
    2,508
    Likes Received:
    0
    Location:
    Third Coast
    So i cant declare something as a string that takes up 4 bytes...

    Such as

    the_string$ = 4

    so the_string only takes up 4 bytes (or does VB do it for me )
     
  5. numnuts

    numnuts New Member

    Joined:
    Apr 26, 2007
    Messages:
    2,508
    Likes Received:
    0
    Location:
    Third Coast
    Disk and memory are very important in this one, so i was actually thinking of storing any integers as a compressed string also :o
     
  6. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    No string will beat a number data type in storage efficiency.

    Dim MyString as String * Length
     
  7. numnuts

    numnuts New Member

    Joined:
    Apr 26, 2007
    Messages:
    2,508
    Likes Received:
    0
    Location:
    Third Coast
    Take this number

    2147483647

    it is 8 bytes as a int but only 4 as a string. So you have that much less in area 0 if it is the primary key ?
     
  8. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    how are you actually storing the data?
     
  9. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    Each character is 8 bits long, longer if it's in Unicode. That number, stored as a string, is 80 bits long, whereas stored as an integer it's 32 bits long.

    Besides, you won't be able to do math on a string without converting it to an integer first, which increases processing overhead.
     
  10. numnuts

    numnuts New Member

    Joined:
    Apr 26, 2007
    Messages:
    2,508
    Likes Received:
    0
    Location:
    Third Coast
    Most of our conversion routines are in macro 64(pretty quick).

    However our compress is in DEC basic (pretty fast)

    Fro example here is the compress routine
    Code:
    1000    FUNCTION STRING COMPRESS(DOUBLE DECI,LONG BYTES,LONG E)
            OPTION TYPE=REAL,SIZE=(INTEGER LONG,REAL DOUBLE)
            DECLARE STRING CONSTANT ZERO.1 = "0"C
            DECLARE STRING CONSTANT ZERO.2 = ZERO.1 + ZERO.1
            DECLARE STRING CONSTANT ZERO.3 = ZERO.2 + ZERO.1
            MAP (EXPAND_MAP) I0$=1%, I1$=1%, I2$=1%, V%     ! I0 I1 I2 VL-VM-VM-VH
            MAP (EXPAND_MAP) O4$=4%, V2$=1%, V1$=1%, V0$=1% ! O4-O4-O4-O4 V2 V1 V0
            MAP (EXPAND_MAP) F1$=1%, O3$=3%                 ! F  O3-O3-O3
            MAP (EXPAND_MAP) F2$=2%, O2$=2%                 ! F  F  O2-O2
            MAP (EXPAND_MAP) F3$=3%, O1$=1%                 ! F  F  F  O1
            MINUS%=DECI<0.                          ! NEGATIVE FLAG
            V=ABS(DECI)
            IF BYTES<5% AND V<2147483648.
            THEN    V%=DECI
                    I0$=V0$
                    I1$=V1$
                    I2$=V2$
                    C128%=MINUS% AND 128%
                    SELECT BYTES
                        CASE 1%
                            COMPRESS=O1$
                            E= V>127.
                        CASE 2%
                            COMPRESS=O2$
                            E= V>32767.
                        CASE 3%
                            COMPRESS=O3$
                            E= V>8388607.
                        CASE 4%
                            COMPRESS=O4$
                            E=0%
                    END SELECT
            ELSE    IN=DECI                         ! SCALE
                    IN=-1-IN   IF MINUS%            ! TWOS COMPLIMENT IF NEGATIVE
                    IN=INT(IN+.00001)               ! CHOP OFF EXTRA
                    TBIN$=""                        ! TEMP OUTPUT STRING
                    FOR I%=1% TO BYTES              ! FOR EACH OUTPUT BYTE...
                            TMP=INT(IN/256%)        ! STRIP LOW BITS FROM IN
                            TMOD%=IN-TMP*256%       ! IN AND 255%
                    TBIN$=CHR$(TMOD% XOR MINUS%)+TBIN$      ! ADD ON TO OUT
                            IN=TMP                  ! UPDATE "IN"
                    NEXT I%
                    E=TMOD%>127% OR IN>0.           ! OVERFLOW CONDITIONS?
                    COMPRESS=TBIN$                  ! LOAD RESULT
            END IF
            END FUNCTION
    
     
  11. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    Okay, that's probably 200-300 assembly functions right there, multiplied by the number of DB queries per second, multiplied again by the number of FK cross-references in each query.

    If I were you, I'd store the PKs and FKs as integers, buy a larger hard drive, and not be penny-wise/pound-foolish by trying to save a little disk space in exchange for wasting a lot of CPU power. There's a reason why databases don't store PKs and FKs as compressed strings by default.
     
  12. numnuts

    numnuts New Member

    Joined:
    Apr 26, 2007
    Messages:
    2,508
    Likes Received:
    0
    Location:
    Third Coast
    That is the thing with the old DEC systems. The CPU is never taxed and you dont need much memory with them because VMS handles it so efficiently. The biggest problem is storage space, and now they want me to interface the PC with the ALPHA server. My only limitation is disk space. There are not any slots left (5 - 2 gig disks) and the only other trays i can find are 4 gigs and are not hotswaps, so i am looking to compress then send instead of send and then compress.

    At the current time we have 4 233 Mghz processors (10%) and 512 megs of memory(usually tons free) but i am having issues with disk space, and they are really cheap bastards and dont want to pay for a raid controller. My only hope is to compress the data before i send it.

    They have been up for 987 days also :mamoru: so they dont ever think there is anything wrong with their system(30 users every day)
     
  13. numnuts

    numnuts New Member

    Joined:
    Apr 26, 2007
    Messages:
    2,508
    Likes Received:
    0
    Location:
    Third Coast
    I laugh because the only solution is for them to upgrade, and i will print out your post and show it to them. For fucks sake you ran a 30 user system for over 10 years its time to spend some money :madfawk:

    Unless you can help :wiggle:
     
  14. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    (shrug) Tell them you've exhausted all other options and if they don't want to replace the DB server itself, they're just going to have to pay for a decent storage array for it to use.
     

Share This Page