+ Reply to Thread
Results 1 to 7 of 7

Write VBA code checks the sign of the difference of 2 given number

  1. #1
    Registered User
    Join Date
    01-19-2014
    Location
    Hanoi
    MS-Off Ver
    Excel 2003
    Posts
    5

    Write VBA code checks the sign of the difference of 2 given number

    Write a VBA code for a subroutine named diŽcheck that checks the sign of
    the difference of two given numbers. The code should have the following structure:

    When run the program should start by opening an InputBox with prompt \Enter
    here a real number:" and title \First number". Once a number has been entered on
    this InputBox another InputBox should open with prompt \Enter here another real
    number:" and title \Second number".

    After the two InputBoxes an IF structure should start which would do the following:
    { If the diŽerence of the numbers entered before is negative a MsgBox should
    appear with prompt \the diŽerence is negative", title \diŽerence sign-check"
    and a single OK button. The value of the difference should then be displayed
    in cell C1 of the Excel Worksheet.
    { If the difference of the numbers is zero a MsgBox should appear with prompt
    \the difference vanishes", title \difference sign-check", a single OK button and
    a Critical Message Icon. The value of the difference should then be displayed
    in cell C1 of the Excel Worksheet.
    { If the difference of the numbers is positive a MsgBox should appear with prompt
    \the difference is positive", title \difference sign-check", a single OK button and
    an Information Message Icon. The value of the difference should then be
    displayed in cell C1 of the Excel Worksheet.
    { Finally, if any of the values entered is not a number, the program should open
    a MsgBox with prompt \this is not a number", title \difference sign-check",
    a single OK button and a Warning Query Icon. In this case, a GOTO
    structure, should make the program start again from the beginning.
    ˛ Assign variables to all prompts and titles so that, for example, you only have to type
    \difference sign-check" once.
    Last edited by sontranhus; 01-19-2014 at 10:32 AM.

  2. #2
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Help me for this VBA

    try this attached file and let me know
    Attached Files Attached Files
    Thanks - Naveed
    -----------------------------
    If the suggestion helps you, then Click * to Add Reputation
    To Attach File: Go Advanced>>Manage Attachments>>Add Files (In Top Right Corner)>>SelectFiles>>.........Locate Your File(s)>>Upload Files>>Done (In Bottom Right)
    1. Use [code] code tags [\code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    2. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Help me for this VBA

    Hi, sontranhus,

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    01-19-2014
    Location
    Hanoi
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Help me for this VBA

    Thank you very much, a great code. I have just study about VBA and hope to receive more help from you

  5. #5
    Registered User
    Join Date
    01-19-2014
    Location
    Hanoi
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Help me for this VBA

    Quote Originally Posted by HaHoBe View Post
    Hi, sontranhus,

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Ciao,
    Holger
    I am really sorry, when i have more then 10 posts I will change this title

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Help me for this VBA

    Hi, sontranhus,

    please take your time and read the request again - you ought to change it by now as the mentioned post was the request to alter the thread title!


    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Ciao,
    Holger

  7. #7
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Write VBA code checks the sign of the difference of 2 given number

    @Hahobe sir

    now the thread title is fine right sir and if not i appologise for my post

    @sontranhus

    Glad i could help you

    If the suggestion helps you, then Click * to Add Reputation

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1