Results 1 to 8 of 8

Thread: Format ??? Resolved

Hybrid View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Talking Re: Format ?[RESOLVED]

    Step$ is a string in my app.

    And thank for helping, that worked nice.

    Reston

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Format ???

    It's not good to let VB coerce the values. You set Step$ = .0003 which generated an error on my system. That's why I changed it.

    As glad as it worked, I'm happy.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Re: Format ??? Resolved

    I'm not getting an error on my system?

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Re: Format ??? Resolved

    Hey do you have any idea why vb was rounding 3 to 2 the way i had things or was that the problem that the format was all wrong.


    Private Sub Command1_Click()
    ee$ = 0.0003
    'tth$ = Abs(Int(Format(ee$, ".####") * 10000))
    step1 = Abs(Int((Format(ee$ * 10000, "#.#####"))))

    End Sub
    I want to make sure that step1 is forced to an interger.Thats why it's in there

    reston

  5. #5
    Addicted Member Luke K's Avatar
    Join Date
    Jun 2004
    Location
    Perth, Australia
    Posts
    183

    Re: Format ??? Resolved

    Well forcing it to an integer means no decimal places, thus, vb must round it Use a double and format it in this way:

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3.     Dim dblL As Double
    4.  
    5.     dblL = 34.32
    6.     MsgBox dblL & vbCrLf & Format(dblL, "##")
    7.  
    8. End Sub

    The output from the MsgBox is:

    34.32
    34
    Artificial Intelligence At War! - The best game of its genre
    Program your own robot and watch it fight in 3d!
    Droidarena 3

    If I have been useful, please Rate My Post

    Support FireFox -
    Microsoft Visual Studio .NET Professional 2003
    Microsoft Visual Studio 6, Enterprise Edition
    Microsoft Windows XP Professional, Service Pack 2

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Format ??? Resolved

    Quote Originally Posted by tiguy
    I'm not getting an error on my system?
    Must be that I have option explicit in every module/form.

    In the VB IDE Click on Tools -> Options, and then tick the box that says
    "Require Variable Declaration" and it will put Option Explicit in every module/form automatically. Only in future projects. You have to paste it into current projects.

    It will then error out when you don't declare a variable or something like trying to set an integer to a string value.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width