Results 1 to 10 of 10

Thread: [RESOLVED] whats wrong here!!!?

  1. #1

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Resolved [RESOLVED] whats wrong here!!!?

    Hi all
    Use Check this code
    VB Code:
    1. Private Sub Form_Load()
    2. Text1.Text = 1000.05
    3. Text1.Text = FormatNumber(Text1.Text, 0)
    4. Text2.Text = 77
    5. MsgBox Val(Text1.Text) - Val(Text2.Text)
    6. End Sub

    Help Urgent!!!!

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: whats wrong here!!!?

    is there any specific reason to use FormatNumber, else try this code using format function
    VB Code:
    1. Private Sub Form_Load()
    2.     Text1.Text = 1000.05
    3.     Text1.Text = Format(Text1.Text, "0")
    4.     Text2.Text = 77
    5.     MsgBox Val(Text1.Text) - Val(Text2.Text)
    6. End Sub
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: whats wrong here!!!?

    Or use this
    VB Code:
    1. MsgBox CLng(Text1.Text) - CLng(Text2.Text)
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  4. #4

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: whats wrong here!!!?

    Ya sir There is a reason
    see the example

    i m using formatnumber because i want to comvet
    1.23 as 1
    1.49 as 1
    1.51 as 2
    1.99 as 2

    so i m using this
    thanks!!

  5. #5
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: whats wrong here!!!?

    yes, Format(Text1.Text, "0") does that...check it and post if any probs...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  6. #6
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: whats wrong here!!!?

    Or
    VB Code:
    1. Text1.Text = FormatNumber(Text1.Text, 0, , , vbFalse)
    will remove the comma and Val will evaluate the value correctly.
    Regards
    Doug

  7. #7

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: whats wrong here!!!?

    i m using formatnumber because i want to comvet
    1.23 as 1
    1.49 as 1
    1.51 as 2
    1.99 as 2
    Due to my this problem shuka ali tell me before two days for using formatnumber function
    but it is show wrong subtraction

    so i want to ask that can i use format function at replacement of formatnumber then what is difference between both this function

    confusion what code i use

    GaneshMorrty Sir Code Of Format Function

    O shuja ali code of Format number

    Help Urgent u both

  8. #8
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: whats wrong here!!!?

    Did you try Doogle's suggestion? That will solve your problem.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  9. #9

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: whats wrong here!!!?

    Checking

  10. #10

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: whats wrong here!!!?

    visual basic code:--------------------------------------------------------------------------------
    Text1.Text = FormatNumber(Text1.Text, 0, , , vbFalse)
    --------------------------------------------------------------------------------
    will remove the comma and Val will evaluate the value correctly.
    Regards
    Doug
    THIS IS PERFECT

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