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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. please help !!!!

please help !!!!

Scheduled Pinned Locked Moved Visual Basic
databasehelp
3 Posts 3 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.
  • P Offline
    P Offline
    peteyshrew
    wrote on last edited by
    #1

    sorry i explained the query wrong. i need to use a button to replace the selected item with the one above, and do the same with the one below. i suppose this code could be modified a bit but dont know how. can anyone help me please. Select Previous: ListBox1().SelectionMode = SelectionMode.One If Me.ListBox1.SelectedIndex > 0 Then Me.ListBox1.SelectedIndex = Me.ListBox1.SelectedIndex - 1 End If Select Next: ListBox1().SelectionMode = SelectionMode.One If Me.ListBox1.SelectedIndex < Me.ListBox1.Items.Count - 1 Then Me.ListBox1.SelectedIndex = Me.ListBox1.SelectedIndex + 1 End If

    G T 2 Replies Last reply
    0
    • P peteyshrew

      sorry i explained the query wrong. i need to use a button to replace the selected item with the one above, and do the same with the one below. i suppose this code could be modified a bit but dont know how. can anyone help me please. Select Previous: ListBox1().SelectionMode = SelectionMode.One If Me.ListBox1.SelectedIndex > 0 Then Me.ListBox1.SelectedIndex = Me.ListBox1.SelectedIndex - 1 End If Select Next: ListBox1().SelectionMode = SelectionMode.One If Me.ListBox1.SelectedIndex < Me.ListBox1.Items.Count - 1 Then Me.ListBox1.SelectedIndex = Me.ListBox1.SelectedIndex + 1 End If

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Stop spamming.

      --- It's amazing to see how much work some people will go through just to avoid a little bit of work.

      1 Reply Last reply
      0
      • P peteyshrew

        sorry i explained the query wrong. i need to use a button to replace the selected item with the one above, and do the same with the one below. i suppose this code could be modified a bit but dont know how. can anyone help me please. Select Previous: ListBox1().SelectionMode = SelectionMode.One If Me.ListBox1.SelectedIndex > 0 Then Me.ListBox1.SelectedIndex = Me.ListBox1.SelectedIndex - 1 End If Select Next: ListBox1().SelectionMode = SelectionMode.One If Me.ListBox1.SelectedIndex < Me.ListBox1.Items.Count - 1 Then Me.ListBox1.SelectedIndex = Me.ListBox1.SelectedIndex + 1 End If

        T Offline
        T Offline
        The ANZAC
        wrote on last edited by
        #3

        oh i think i understand, you want the selected item on button press to have the same value as the next or previous item. If that is the case: Make sure your listbox selectionmode = selectionmode.multiextended Select all: ListBox1().SelectionMode = SelectionMode.MultiExtended For i As Integer = 0 To Me.ListBox1.Items.Count - 1 Me.ListBox1.SetSelected(i, True) Next Change current to same as previous: ListBox1().SelectionMode = SelectionMode.One Dim Selected As Integer = Me.ListBox1.SelectedIndex Dim newItem As String If Me.ListBox1.SelectedIndex > 0 Then newItem = Me.ListBox1.Items.Item(Selected - 1) Me.ListBox1.Items.RemoveAt(Selected) Me.ListBox1.Items.Insert(Selected, newItem) Me.ListBox1.SelectedIndex = Selected End If Change current to same as next: ListBox1().SelectionMode = SelectionMode.One Dim Selected As Integer = Me.ListBox1.SelectedIndex Dim newItem As String If Me.ListBox1.SelectedIndex < Me.ListBox1.Items.Count - 1 Then newItem = Me.ListBox1.Items.Item(Selected + 1) Me.ListBox1.Items.RemoveAt(Selected) Me.ListBox1.Items.Insert(Selected, newItem) Me.ListBox1.SelectedIndex = Selected End If

        Posted by The ANZAC

        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