Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. please help me with combobox keycode

please help me with combobox keycode

Scheduled Pinned Locked Moved Visual Basic
helpgame-dev
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bapu2889
    wrote on last edited by
    #1

    hi i am working on my assingment about pong game and it's almost done but i just want to provide control option for user so they can select their choice for control keys to control right and left paddle so i have use module to pass the info. for another form but it's not working, so can anybody help me with this ''' this is the code for module Module Module1 Public MyKeys(4) As Keys Public Sub main() Dim MyForm1 As New frmStart MyForm1.Show() Application.Run() End Sub End Module ''''' this is for form load Private Sub frmStart_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load cboKey1.Items.Add(Keys.Up) cboKey1.Items.Add(Keys.Down) cboKey1.Items.Add(Keys.Right) cboKey1.Items.Add(Keys.Left) cboKey1.Items.Add(Keys.A) cboKey1.Items.Add(Keys.Z) cboKey1.Items.Add(Keys.K) cboKey1.Items.Add(Keys.M) cboKey1.Items.Add(Keys.S) cboKey1.Items.Add(Keys.X) cboKey1.SelectedIndex = 0 For I As Integer = 0 To cboKey1.Items.Count - 1 cboKey2.Items.Add(cboKey1.Items.Item(I)) cboKey3.Items.Add(cboKey1.Items.Item(I)) cboKey4.Items.Add(cboKey1.Items.Item(I)) Next cboKey2.SelectedIndex = 0 cboKey3.SelectedIndex = 0 cboKey4.SelectedIndex = 0 MyKeys(1) = cboKey1.SelectedItem MyKeys(2) = cboKey2.SelectedItem MyKeys(3) = cboKey3.SelectedItem MyKeys(4) = cboKey4.SelectedItem Timer1.Enabled = True End Sub''' and this code is for keydown event for another form Private Sub frmPong_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown For J As Integer = 1 To 4 Select Case MyKeys(J) Case MyKeys(1) MyBat1.Y -= 10 Case MyKeys(2) MyBat1.Y += 10 Case MyKeys(3) MyBat2.Y -= 10 Case MyKeys(4) MyBat2.Y += 10 End Select Next End Sub''''' and code for button click Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim MyForm As New frmPong MyForm.Show() MyKeys(1) = cboKey1.SelectedIndex MyKeys(2) = cboKey2.SelectedIndex MyKeys(3) = cboKey3.SelectedIndex MyKeys(4) = cboKey4.SelectedIndex Me.Hide() End Sub ' ' so when application start the first form shows option for user and when user click buttton it's load selected controls for user that's the hole idea please help me with this problem :(( :confused: please please please

    L 1 Reply Last reply
    0
    • B bapu2889

      hi i am working on my assingment about pong game and it's almost done but i just want to provide control option for user so they can select their choice for control keys to control right and left paddle so i have use module to pass the info. for another form but it's not working, so can anybody help me with this ''' this is the code for module Module Module1 Public MyKeys(4) As Keys Public Sub main() Dim MyForm1 As New frmStart MyForm1.Show() Application.Run() End Sub End Module ''''' this is for form load Private Sub frmStart_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load cboKey1.Items.Add(Keys.Up) cboKey1.Items.Add(Keys.Down) cboKey1.Items.Add(Keys.Right) cboKey1.Items.Add(Keys.Left) cboKey1.Items.Add(Keys.A) cboKey1.Items.Add(Keys.Z) cboKey1.Items.Add(Keys.K) cboKey1.Items.Add(Keys.M) cboKey1.Items.Add(Keys.S) cboKey1.Items.Add(Keys.X) cboKey1.SelectedIndex = 0 For I As Integer = 0 To cboKey1.Items.Count - 1 cboKey2.Items.Add(cboKey1.Items.Item(I)) cboKey3.Items.Add(cboKey1.Items.Item(I)) cboKey4.Items.Add(cboKey1.Items.Item(I)) Next cboKey2.SelectedIndex = 0 cboKey3.SelectedIndex = 0 cboKey4.SelectedIndex = 0 MyKeys(1) = cboKey1.SelectedItem MyKeys(2) = cboKey2.SelectedItem MyKeys(3) = cboKey3.SelectedItem MyKeys(4) = cboKey4.SelectedItem Timer1.Enabled = True End Sub''' and this code is for keydown event for another form Private Sub frmPong_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown For J As Integer = 1 To 4 Select Case MyKeys(J) Case MyKeys(1) MyBat1.Y -= 10 Case MyKeys(2) MyBat1.Y += 10 Case MyKeys(3) MyBat2.Y -= 10 Case MyKeys(4) MyBat2.Y += 10 End Select Next End Sub''''' and code for button click Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim MyForm As New frmPong MyForm.Show() MyKeys(1) = cboKey1.SelectedIndex MyKeys(2) = cboKey2.SelectedIndex MyKeys(3) = cboKey3.SelectedIndex MyKeys(4) = cboKey4.SelectedIndex Me.Hide() End Sub ' ' so when application start the first form shows option for user and when user click buttton it's load selected controls for user that's the hole idea please help me with this problem :(( :confused: please please please

      L Offline
      L Offline
      Lucky Sheikh
      wrote on last edited by
      #2

      first of all u hv to add a items in combobox if u want to retrieve the data in second form of combobox then write code firstform.combobox.items() or save the data in database table n retrive in combobox oke hope u understand byeeeeee lucky

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups