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. listbox in vb.net

listbox in vb.net

Scheduled Pinned Locked Moved Visual Basic
csharphelpquestion
4 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.
  • A Offline
    A Offline
    Anusubha V G
    wrote on last edited by
    #1

    I need to add the item and value in the list box. I add this using strtext and strvalue respectively. But the strvalue i need to add is a string. so that the value when adding cannot get duplicated. How can i add string value to strvalue I am taking this values from two textboxes My coding is as follows.... Dim i As Integer Dim item As New Item For i = 0 To ListBox1.Items.Count - 1 item = ListBox1.Items(i) If TextBox1.Text = item.strValue Then MsgBox("Already you have added this link", MsgBoxStyle.Information, "Knowledge Base") Exit Sub End If Next item.strText = Textbox2.Text item.strValue = TextBox1.Text lstLinks.Items.Add(item) txtWebLinkDescriptions.Text = "" txtWebLinks.Text = "" It shows that the string value cannot be bind to integer value.... May u help me to solve these please.... Thanks in advanvce........

    N C 2 Replies Last reply
    0
    • A Anusubha V G

      I need to add the item and value in the list box. I add this using strtext and strvalue respectively. But the strvalue i need to add is a string. so that the value when adding cannot get duplicated. How can i add string value to strvalue I am taking this values from two textboxes My coding is as follows.... Dim i As Integer Dim item As New Item For i = 0 To ListBox1.Items.Count - 1 item = ListBox1.Items(i) If TextBox1.Text = item.strValue Then MsgBox("Already you have added this link", MsgBoxStyle.Information, "Knowledge Base") Exit Sub End If Next item.strText = Textbox2.Text item.strValue = TextBox1.Text lstLinks.Items.Add(item) txtWebLinkDescriptions.Text = "" txtWebLinks.Text = "" It shows that the string value cannot be bind to integer value.... May u help me to solve these please.... Thanks in advanvce........

      N Offline
      N Offline
      Nanda1605
      wrote on last edited by
      #2

      Hi, I think this code will help you... Dim i As Integer For i = 0 To ListBox1.Items.Count - 1 If ListBox1.Items(I).Tostring = TextBox1.Text Then MsgBox("Already you have added this link", MsgBoxStyle.Information, "Knowledge Base") Exit Sub End If Next lstLinks.Items.Add(TextBox1.Text)

      Thanks, Nanda

      A 1 Reply Last reply
      0
      • A Anusubha V G

        I need to add the item and value in the list box. I add this using strtext and strvalue respectively. But the strvalue i need to add is a string. so that the value when adding cannot get duplicated. How can i add string value to strvalue I am taking this values from two textboxes My coding is as follows.... Dim i As Integer Dim item As New Item For i = 0 To ListBox1.Items.Count - 1 item = ListBox1.Items(i) If TextBox1.Text = item.strValue Then MsgBox("Already you have added this link", MsgBoxStyle.Information, "Knowledge Base") Exit Sub End If Next item.strText = Textbox2.Text item.strValue = TextBox1.Text lstLinks.Items.Add(item) txtWebLinkDescriptions.Text = "" txtWebLinks.Text = "" It shows that the string value cannot be bind to integer value.... May u help me to solve these please.... Thanks in advanvce........

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        The easy way is to build a dictionary where the key is the strValue, or just a list of strings, even. Do a search, if the value is in there, then it's been added already.

        Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        1 Reply Last reply
        0
        • N Nanda1605

          Hi, I think this code will help you... Dim i As Integer For i = 0 To ListBox1.Items.Count - 1 If ListBox1.Items(I).Tostring = TextBox1.Text Then MsgBox("Already you have added this link", MsgBoxStyle.Information, "Knowledge Base") Exit Sub End If Next lstLinks.Items.Add(TextBox1.Text)

          Thanks, Nanda

          A Offline
          A Offline
          Anusubha V G
          wrote on last edited by
          #4

          Thank u for ur response Nanda But, my question is how to get the value of the item in case of string ie, since because the value i use here is a string, it displays error as "Conversion from string to type integer is not valid" will u please tell me how to get the string value for the item ie, i need to use string value for item.strvalue Thank u once again

          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