Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Basic horrible stuff

Options
  • 23-04-2003 3:20pm
    #1
    Registered Users Posts: 6,240 ✭✭✭


    Ok this is what I have
    OPEN "Files\Kevin.txt" FOR OUTPUT AS #121
    
       DIM divi AS Integer
       DIM modu AS Integer
       DIM x    AS Integer
    
       PRINT #121, "BUNDLE,", "PGNUM"
       FOR x = 1 TO 2300
           divi = (x / 1000)
           divi = divi + 1
           modu = x MOD 1000
          PRINT #121, FORMAT$( divi, "00" ), "," , FORMAT$( modu, "0000")
       NEXT x     
    
    so essentially what i want is output like this
    BUNDLE, PGNUM
    01,0001
    01,0002
    01,0003
    01,0004
    ...

    but when I get to record 500 I get this
    02,0500
    02,0501

    now I presume this is cause 500/1000 = .5 round up to 1?
    is there anyway to stop this rounding?


Comments

  • Registered Users Posts: 1,931 ✭✭✭Zab


    Try using a backslash instead of a forwardslash.

    Zab.


  • Registered Users Posts: 6,240 ✭✭✭hussey


    I didn't even notice that!!

    what was i asking with '/'??

    and what was I asking with '\'?


  • Registered Users Posts: 629 ✭✭✭str8_away


    Used to divide two numbers and return an integer result.

    Syntax

    result = number1\number2

    The \ operator syntax has these parts:

    Part Description
    result Required; any numeric variable.
    number1 Required; any numeric expression.
    number2 Required; any numeric expression.


  • Registered Users Posts: 629 ✭✭✭str8_away


    x/y = int(x\y)


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    Another thing, not your problem but something I tried to avoid is static filehandle id's.

    instead of...

    OPEN "Files\Kevin.txt" FOR OUTPUT AS #121

    try (been a while, so syntax may vary)...

    ffh = FreeFile
    OPEN "Files\Kevin.txt" FOR OUTPUT AS #ffh

    and don't forget...

    close #ffh


  • Advertisement
Advertisement