Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 2nd, 2007, 04:16 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default Overflow problems!

What variable type could hold 6 digits, because integers don't and longs don't?
Code:
Round(Sin(Rnd()), 6)
That code returns a 6 digit number and i just need to store it in variable that isn't a string.

Thanks


------------------------------------------------
Apocolypse2005
Always ready and waiting to be helped!
__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old September 2nd, 2007, 11:26 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

You can use Double

Sub No()
Dim dbl As Double

 dbl = Round(Sin(Rnd()), 6)
End Sub

Cheers
Shasur

http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old September 4th, 2007, 10:51 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Actually, a Long can.
I put the following into VB 6 as a test.
Read the comments for the behavior:
Code:
Private Sub Form_Click()

    Dim L As Long
        L = 999999
        L = 9999999
        L = 99999999
        L = 999999999         ' In fol. stmts, VB supplied the “#”
        L = 9,999,999,999#    ' <——<<< This was where the o-flow occurred.
        L = 99999999999#      ' (I added the commas for clarity.)
        L = 999999999999#     ' It didn't fail till 10 digits.
        . . .





Similar Threads
Thread Thread Starter Forum Replies Last Post
ListBox - overflow possible? snufse ASP.NET 2.0 Basics 0 July 25th, 2008 09:50 AM
Overflow grstad Classic ASP Databases 18 December 14th, 2006 10:06 AM
Overflow Error mateenmohd Classic ASP Basics 4 July 5th, 2005 02:12 AM
Buffer Overflow rekha_jsr Oracle 3 February 3rd, 2005 08:11 PM
can anybody tell why i am getting overflow error tulsi15 SQL Server 2000 1 December 15th, 2004 07:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.