Results 1 to 10 of 10

Thread: Calculation Problem

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2011
    Posts
    34

    Calculation Problem

    Hi guys,

    I have some problem with the calculation.

    When I press "0.01", it came out
    0.0(When I press 0.0)
    1(When I press 1)

    What happen to my calculation?

    Code:
    Private Sub Command0_Click()
    
    If (text1.Text = 0) Then
        If (Shift = True) Then
            text1.Text = "0.0"
            Shift = False
        Else
            text1.Text = "0"
        End If
    
    Else
    text1.Text = text1.Text & "0"
    End If
    
    End Sub
    If u guys dont understand, it cannot have 0.01, 0.02....etc..

    only 0.0
    and then go back to 1.

    Help!

  2. #2
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

    Re: Calculation Problem

    What's the code inside your "Command1_Click" event?
    Hooked for good.

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2011
    Posts
    34

    Re: Calculation Problem

    Here's my command 1 click
    Code:
    Private Sub Command1_Click()
    
    
    
    If (text1.Text = 0) Then
        If (Shift = True) Then
            text1.Text = "0.1"
            Shift = False
        Else
            text1.Text = "1"
        End If
    Else
    text1.Text = text1.Text & "1"
    End If
    
    End Sub
    and my decimal event

    Code:
    Private Sub cmdDot_Click()
    
    Me.shiftPos
    
    End Sub

  4. #4
    New Member
    Join Date
    Nov 2011
    Location
    ElJadida, Morroco
    Posts
    4

    Re: Calculation Problem

    Hi,

    I can't figure out what you are trying to do , so pleaze try to explain so we can help you .

    Cordially

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2011
    Posts
    34

    Re: Calculation Problem

    Quote Originally Posted by S!dox View Post
    Hi,

    I can't figure out what you are trying to do , so pleaze try to explain so we can help you .

    Cordially
    I am trying to output 0.01 to the textbox but it cannot. It goes up to 0.0 and when I press 1 it became 1, not 0.01

    so its like
    0
    0.
    0.0
    1

    You get it now?

  6. #6
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

    Re: Calculation Problem

    In your code for cmdDot_click, what on earth is "Me.shiftPos"? Is it from some library?
    Hooked for good.

  7. #7

    Thread Starter
    Member
    Join Date
    Nov 2011
    Posts
    34

    Re: Calculation Problem

    It's a way to display the dot.

    What am I going to do now?

    Help!

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Calculation Problem

    What is Shift and what is ShiftPos?

    They must be functions/subs that you wrote.

    Why don't you zip up your project and attach it so we can see the same things that you are seeing?

  9. #9
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: Calculation Problem

    Try changing
    Code:
    If text1.Text = 0 Then
    with
    Code:
    If text1.Text = "0" Then
    and see if it works for you.

    Also tell us if you have any code in your text1_Change() or text1_KeyPress() events.
    If your problem is solved, then drag down the Thread Tools and mark your thread as Resolved.

    If I helped you solve your problem, inflate some air into my ego by rating my post and adding a comment too.

    For notorious issues (elaborate yourself) contact me via PM. I don't answer them in the forums EVER.

  10. #10

    Thread Starter
    Member
    Join Date
    Nov 2011
    Posts
    34

    Re: Calculation Problem

    Quote Originally Posted by lone_REBEL View Post
    Try changing
    Code:
    If text1.Text = 0 Then
    with
    Code:
    If text1.Text = "0" Then
    and see if it works for you.

    Also tell us if you have any code in your text1_Change() or text1_KeyPress() events.
    You solved my problem. You're genius. + REP!

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