Jump to content
xisto Community
Plenoptic

Selecting Only Parts Of Text For Use (vb6 Coding)

Recommended Posts

Ok so I have a list and I am trying to make a click event that transfers the value of that item on the list to a text box to edit it. The only problem is I have a label for each item as Item 1: Item 2: etc; (not item exactly). So what I want to do is before the transfer is made have it select the "Item #" part and delete it so it is just the item name itself. It is sort of confusing but I was pretty sure it could be done. Any help would be appreciated.

Share this post


Link to post
Share on other sites

Ok so I have a list and I am trying to make a click event that transfers the value of that item on the list to a text box to edit it. The only problem is I have a label for each item as Item 1: Item 2: etc; (not item exactly). So what I want to do is before the transfer is made have it select the "Item #" part and delete it so it is just the item name itself. It is sort of confusing but I was pretty sure it could be done. Any help would be appreciated.


I've been programming in VB 6 for about 10 years now. I'm confused on exactly what you want. Could you explain it in different words?

Share this post


Link to post
Share on other sites

Ok so I have a list and I am trying to make a click event that transfers the value of that item on the list to a text box to edit it. The only problem is I have a label for each item as Item 1: Item 2: etc; (not item exactly). So what I want to do is before the transfer is made have it select the "Item #" part and delete it so it is just the item name itself. It is sort of confusing but I was pretty sure it could be done. Any help would be appreciated.

I think I understand you. This is what I would do:

Private Sub Form_Load()
'additems to list1
With List1
.AddItem "abc", 0
.AddItem "def", 1
.AddItem "ghi", 2
.AddItem "jkl", 3
End With

'Name the Label1's
For x = 0 To 3 Step 1
Label1(x) = "Item #" & x + 1
Next x

End Sub

Private Sub List1_Click()

'restore the Label1 names
For x = 0 To 3 Step 1
Label1(x) = "Item #" & x + 1
Next x

'Set Label1's caption to the list1 selection
Label1(List1.ListIndex).Caption = List1.Text

'Text1's text is the selected item's name
Text1.Text = List1.Text

End Sub


Just create an array of labels named Label1(four of them), a listbox named List1, and a textbox named Text1. I think it is pretty straight-forward.

Share this post


Link to post
Share on other sites

Thanks for the help, although I found a different way which did have some of yours in there. You see I had items in a list but also extra text before the item name so it was labled "Question 1 = xxxxx" That in quotations is the whole item on the list. I wanted to make it so when people double clicked on the item it would transfer just the "xxxxx" to the text box for editting which I ended up doing with a search and replace script for strings.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.