Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Proper command to round up a number {VBscript question}

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
I would like to take a number, devide it by 10, then round it upto the next number if any remainders were found. but dont seem to know the proper command if i were to round it down, I'd just use abs(), but using round() well it just seems to round down too.<br><br>for those of you who want to know the purpose to this, the number being devided is the number of records, each page has 10 records, when I round up because there is some extra, the final number is the number of pages all the records occupy <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
oh did I mention this isnt client-side scripting, so if you know any easy commands for this for server-side (as in Active Server Pages) feel free to say so as well. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Try this:<br>Public Function NumPages(Records As Long) As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;NumPages = Round(Records / 10)<br>&nbsp;&nbsp;&nbsp;&nbsp;If (Records Mod 10) &gt; 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NumPages = NumPages + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>End Function<br>
 
hmm for some reason it keeps returning a zero<br><br>&lt;TD align=right&gt;&lt;Strong&gt;Page 1 of <br>&lt;%<br>Dim NumPages<br>NumPages = Round(rsInven.MaxRecords / 10)<br>If (rsInven.MaxRecords Mod 10) &gt; 0 Then<br> NumPages = NumPages + 1<br>End If<br>Response.Write NumPages<br>%&gt;&lt;/Strong&gt;&lt;/TD&gt;<br><br>Also you can not declare longs in VBscript, everything is a variant when it comes to web applications. (oh ignore the 1 of.., I havent wrote the code to determine the current page yet)<br> <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Heres the funny thing I found out, when I made it spit out the MaxRecords, showed me as zero, I'll try to find out what other properties tells me the nubmer of records, then try your function again. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
I am using RecordCount property but I keep getting back a -1 , and I have the cursor type of odOpenStatic, from what I know anything other than Static or Keyset will not return the number of records, and dynamic only returns the actual depending on the type of data source, so using static I should get back the number, but i dont. hmm <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
My co-worker josh has figured it out when I went out to lunch<br><br> rsInven.Open &quot;SELECT Type.Name AS Type, Location.Name AS Location, User.fName AS Ownerf, User.lName AS Ownerl, User_1.fName AS Userf, User_1.lName AS Userl, Inventory.Name, Inventory.Description, Inventory.Value FROM Location INNER JOIN (User AS User_1 INNER JOIN (User INNER JOIN (Type INNER JOIN Inventory ON Type.ID = Inventory.Type) ON User.ID = Inventory.Owner) ON User_1.ID = Inventory.User) ON Location.ID = Inventory.Location;&quot;, cnInven, 3, 3<br><br>I have yet to ask him to explain how the &quot;3, 3&quot; got it to work. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Yep, now that I got that solved, the code you gave me also now works, and I did happen to just forget about the Mod function. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top