8 Replies - 440 Views - Last Post: 29 September 2012 - 09:47 PM Rate Topic: -----

#1 Nkenny94  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-September 12

Key Up does'nt work with show ()

Posted 29 September 2012 - 11:21 AM

Private Sub Orer_KeyUp(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
        If e.KeyCode = Keys.N Then
            Order.Show()
            Me.Close()

I don't know why this doesn't work but well i try at other Key Up (other thing) then it work.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text <> String.Empty And TextBox2.Text <> String.Empty Then
            Me.Hide()
            uneM.Show()

I'm newbie in this so please help.

Is This A Good Question/Topic? 0
  • +

Replies To: Key Up does'nt work with show ()

#2 Nkenny94  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-September 12

Re: Key Up does'nt work with show ()

Posted 29 September 2012 - 11:27 AM

Second Code is:
  Private Sub Order_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
        If e.KeyCode = Keys.Q Then
            ListBox1.Items.Add("Burger")
            ListBox2.Items.Add("4.50")


wrong code :P
Was This Post Helpful? 0
  • +
  • -

#3 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Key Up does'nt work with show ()

Posted 29 September 2012 - 12:34 PM

What doesn't work? If you can't add new item to listview, try it like this:
        If e.KeyCode = Keys.Q Then
            Dim itm As New ListViewItem With {.Text = "some text"}
            itm.SubItems.Add("blah")
            ListView1.Items.Add(itm)
        End If




If your problem is with .Show(), what is Order? A form? You also have Orer_KeyUp (d is missing in Orer).

Edit:
In Form1_Load method add: Me.KeyPreview = True. I think this is what you are having problems with.


Edit 2:
I now see you have ListBox not ListView. My mistake. Anyway, Edit 1 should do the job for you.

This post has been edited by lucky3: 29 September 2012 - 12:53 PM

Was This Post Helpful? 0
  • +
  • -

#4 Nkenny94  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-September 12

Re: Key Up does'nt work with show ()

Posted 29 September 2012 - 12:55 PM

I get wrong the first code not the second. I don't know what mistake i make but when i run the debug it's doesn't work
Private Sub Orer_KeyUp(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
        If e.KeyCode = Keys.N Then
            Order.Show()
            Me.Close()



Was This Post Helpful? 0
  • +
  • -

#5 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Key Up does'nt work with show ()

Posted 29 September 2012 - 12:58 PM

Again: you have Orer
Was This Post Helpful? 0
  • +
  • -

#6 Nkenny94  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-September 12

Re: Key Up does'nt work with show ()

Posted 29 September 2012 - 01:06 PM

still not work >"<
I'm trying to switch form to form by key stroke.
After add Key Preview but it still not work :-?
Full code again:(
Public Class uneM
    Private Sub Order_KeyUp(sender As System.Object, e As System.Windows.Forms.KeyEventArgs)
        If e.KeyCode = Keys.N Then
            Order.Show()
            Me.KeyPreview = True
            Me.Close()
        Else
            If e.KeyCode = Keys.O Then
                Order.Show()
                Me.Close()
            Else
                If e.KeyCode = Keys.P Then
                    Pwpro.Show()
                    Me.Close()
                Else
                    If e.KeyCode = Keys.L Then
                        LogOut.Show()
                        Me.Close()

                    End If
                End If
            End If
        End If
    End Sub

Was This Post Helpful? 0
  • +
  • -

#7 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Key Up does'nt work with show ()

Posted 29 September 2012 - 01:14 PM

Order is active Form, right? What are you trying to do with Order.Show? Show another form? Me.KeyPreview = True should be in Order_Load method.
Was This Post Helpful? 1
  • +
  • -

#8 Nkenny94  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-September 12

Re: Key Up does'nt work with show ()

Posted 29 September 2012 - 01:40 PM

It's work now thanks. :D 1 more question :P how do you count the total number in the listbox, i'm a bit confuse with it
Public Class Order
    Private Sub Order_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
        If e.KeyCode = Keys.Q Then
            ListBox1.Items.Add("Burger")
            ListBox2.Items.Add("4.50")
        Else
            If e.KeyCode = Keys.W Then
                ListBox1.Items.Add("Fries")
                ListBox2.Items.Add("0.99")
            Else
                If e.KeyCode = Keys.A Then
                    ListBox1.Items.Add("Coca Cola")
                    ListBox2.Items.Add("0.99")
                Else
                    If e.KeyCode = Keys.S Then
                        ListBox1.Items.Add("Fries Chicken")
                        ListBox2.Items.Add("2.99")
                    Else
                        If e.KeyCode = Keys.Z Then
                            ListBox1.Items.Add("Pizza")
                            ListBox2.Items.Add("4.99")
                        Else
                            If e.KeyCode = Keys.X Then
                                ListBox1.Items.Add("7Up")
                                ListBox2.Items.Add("0.99")
                            Else
                                If e.KeyCode = Keys.P Then
                                    Me.Hide()
                                    VAT.Show()
                                End If

                            End If
                        End If
                    End If
                End If
            End If
        End If
    End Sub

Was This Post Helpful? 0
  • +
  • -

#9 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Key Up does'nt work with show ()

Posted 29 September 2012 - 09:47 PM

Total number of elements in listbox: ListBox1.Items.Count
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1