Results 1 to 18 of 18

Thread: what am i doing wrong [Solved] [02/03]

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    46

    Resolved what am i doing wrong [Solved] [02/03]

    hello, i am trying to make a stand alone cashregister program. everything works fine exept when it askes for a tender. it is designed to be used on a touch screen so it has an onscreen keyboard with all the keys. but there is an issue. it is set up so when you hit the 'pay' key on the main form it opens up a new diolog box with the onscreen keyboard. when ever i hit the '0' key it closes the diolog box.

    here is the code for when the pay key is clicked:
    Code:
        Private Sub btnPay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPay.Click
            Dim Pay As New Pay 'diolog with keypad
            Dim responce As MsgBoxResult
    
            Pay.total = total ' transfer the total to the diolog box
            Pay.ShowDialog() 'show the diolog box
            responce = Pay.DialogResult 'if payment compleate
            If responce = MsgBoxResult.OK Then 'if payment is accepted
                till = till + total 'add the order to the till
                clear_transaction() ' start new transaction
            End If
    
    
        End Sub
    here is the code that is ran when a user hits the 0 key
    Code:
       Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
            amtentered = amtentered & "0" 'add 0 to the end of the tender
            format() ' format it in currency style
        End Sub
    
    Private Sub format()
    'an amount of $12.00 is stored as 1200, the next line of code will put the decmial point in the right place.
            itemamt.Text = FormatCurrency(amtentered / 100)
    
        End Sub
    i am new to programing any help is apprecated. if you need more information please let me know, thanks!
    Last edited by tonyrueb; Jun 26th, 2007 at 02:19 PM.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: what am i doing wrong [02/03]

    format is a keyword in VB.... try changing it to something else.

    Or use Me.Format instead.

    Lastly, check your option settings and make sure OPTION STRICT and OPTION EXPLICIT are set.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    46

    Re: what am i doing wrong [02/03]

    as i said i am new to programing, how do i use the option strict and option explicit? and what does it do?

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: what am i doing wrong [02/03]

    Put on the very top of your code page:
    Option Strict On
    Option Explicit On

    It helps reducing errors and speeds up code execution.

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: what am i doing wrong [02/03]

    option explicit ensures the you explicitly define your variables and objects before you actually use them.

    Option strict prevents you from doing implicit conversion ie: numbers to strings or strings to numbers.

    They would be under Tools -> Options... you may have to dig around a little for it. Where it's located inVS2002 (which I don't have) is different from VS2005 (which I have)

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    46

    Re: what am i doing wrong [02/03]

    so far nothing seems to work, any other ideas?

  7. #7
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: what am i doing wrong [02/03]

    What's the problem? If you want to close the form when btn0 is clicked, then you should set the returned dialogresult value in the click evewnt handler, then close the form
    Code:
     Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
            amtentered = amtentered & "0" 'add 0 to the end of the tender
            format() ' format it in currency style
            Me.DialogResult = Windows.Forms.DialogResult.OK
            Me.Close()
        End Sub

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: what am i doing wrong [02/03]

    Stan - I think you have it backwards.... currently it IS shutting down, when it shouldn't....

    Tony - put a breakpoint on the first line of the code for the 0 button..... when it stops, right click, select Toggle->Break on all Errors.... then step thorugh using F10..... at some point it should either break or you'll see where it's going..


    Ah, wait, try this too.... in design mode..... select the form, then show the properties for the form (F4).... look for a property that reads "Default Button"... or close to it.... make sure it isn't set to your 0 button. In fact make sure it reads "None".

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: what am i doing wrong [02/03]

    Can't remember quite right, but isn't there a AcceptButton and CancelButton property for a form in 02/03, or is that just in 05? If those form properties exist, make sure that neither of them is set to your zero button, as well.
    My usual boring signature: Nothing

  10. #10

    Thread Starter
    Member
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    46

    Re: what am i doing wrong [02/03]

    ok after doing a steping though the code it goes though all the code first the code for the 0 key then the format code then it finishes off the 0 code then it goes back to the pay sub on the frist form finshes all the lines of that. then after that that is when the form closes.

    if that makes sense?

    yes VB 03 does have a defalt button setting.

  11. #11
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: what am i doing wrong [02/03]

    It goes through the first button, THEN it goes through a totally different button handler? That's impressive!! I assume that you don't explicitly call the second button handler. Is there any chance that the other button managed to get located under the 0 button?
    My usual boring signature: Nothing

  12. #12

    Thread Starter
    Member
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    46

    Re: what am i doing wrong [02/03]

    i wish i knew more about programing so i could explane it better...

    when ever a user presses a number it updates a text box. when i want to type in $20.75 they would type 2075, as you press the keys it turns it into the correct format:
    $.02, .20, 2.07, 20.75

    this is what the format() sub is for
    Code:
        Private Sub formatcur()
            itemamt.Text = FormatCurrency(amtentered / 100)
    
        End Sub

  13. #13
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: what am i doing wrong [02/03]

    You say the dialog box with the onscreen keybord closes when hitting the 0 key, so it doesn't close on other keys, could you show us the code for such a key?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  14. #14

    Thread Starter
    Member
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    46

    Re: what am i doing wrong [02/03]

    here is the code for the 0 key

    Code:
    Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
            amtentered = amtentered & "0" 'add 0 to the end of the tender
            formatcur() ' format it in currency style
        End Sub
    This is the code for the Formatcur() sub

    Code:
        Private Sub formatcur()
            itemamt.Text = FormatCurrency(amtentered / 100)
        End Sub

  15. #15
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: what am i doing wrong [02/03]

    I was asking for the code of another key, not the one for "0"!!!!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  16. #16
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    413

    Re: what am i doing wrong [02/03]

    Try adding anohter button that does the same thing as the zero, but call it "zero" and see if it does the same thing.
    Visual Studio .NET 2005/.NET Framework 2.0

  17. #17

    Thread Starter
    Member
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    46

    Re: what am i doing wrong [02/03]

    here is the code for the 9 key

    Code:
        Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
            amtentered = amtentered & "9"
            formatcur()
        End Sub

  18. #18

    Thread Starter
    Member
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    46

    Re: what am i doing wrong [02/03]

    i figgered it out, the dialog result setting was set to cancel

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