![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2006
Posts: 7
Rep Power: 0
![]() |
help with VB 6.3 code/function type of thing.
HI,
Im new to programming and i am doing a project for sixth form(college). I cant find info on a prob i have so i thought id ask someone experienced. Basically im creating some order forms and have almost no syntax knowledge...so far i can buy and add things but not remove...thats the prob. When i click the remove button, the highlighted item on the list box should be removed and that which is below should move up. The list box uses a Row Source, and the source is on a worksheet...hm. If i could get the highlighted item copied to the worksheet that would be enough as i could take it from there. Basically i cant relate a commmand buton to a list box, thats how non-existant my knowledge is. Private Sub CommandButton2_Click() End Sub Its all i have at mo for the button. Any help would be great. Sorry if anything is unclear. thnx. |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Apr 2005
Posts: 218
Rep Power: 4
![]() |
Its quite hard to understand what your trying to do, but this is how I would do what you want.
So basically you have a list box and you select items of that list that go into some sort of text box (hope im right), and you also want a button that will clear somthing thats in that text box. For this you could have a button named somthing like "Clear text" or somthing with a similar name, and in that code you will have somthing like Private Sub Command1_Click() Text1.Text = "" Text2.Text = "" List1.Clear List2.Clear The line Text1.text = "" Text2.text = "" List1.Clear List2.Clear So basically just customise those four lines of code to the Items that you want to use them for. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Apr 2006
Posts: 7
Rep Power: 0
![]() |
If i could somehow post a pic of my form then itll be clearer...but posting a pic would require a host website, would it???
dunno much about the net. not my thing....going on to become an engineer ![]() thnx zorin. I was trying to delete somthing off a listbox...doesnt seem to work the same for a text box. The thing i click on within the textbox becomes highlighted blue...then when i click remove(command buton)....it removes that highlighted one from the list box, thats my aim. im not using text boxes. I thought the code might include something like , upon clicking Remove.listbox1.selected.value (this is just to give idea) errm if this clarifies it a bit more. Thnx seeya. |
|
|
|
|
|
#4 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
You can host images at www.imageshack.us
![]() |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Apr 2006
Posts: 7
Rep Power: 0
![]() |
sweet! gracias for the link Polyphemus. this pic'll give a better idea of what im after. btw my coursework is due in 2 weeks time.
![]() Thanks to ImageShack for Free Image Hosting hmmm good service, better than i was expecting. so from this pic and the initial thread hopefully u would be able to advise me on my prob. thnx for taking the time. |
|
|
|
|
|
#6 |
|
Hobbyist Programmer
Join Date: Apr 2005
Posts: 218
Rep Power: 4
![]() |
OK so here is what you would do. I take it that the Items shown on that list have been added to the
Private Sub Form_Load() List1.AddItem ("you Information here")
List1.AddItem ("you Information here again")List1.RemoveItem (0) There is one way that I know of how to avoid this and that is if you know what items need to be deleted you can so this for example the 6th item on your list you would use the code List1.RemoveItem (6) Just to make sure you get that the first line would be (1) and the second (2) and so on and on and on and on ![]() I haven't tested this code...its just stuff that I remember so it might not be all completly right. Someone else might see this thread though and be able to go into more detail. |
|
|
|
|
|
#7 |
|
Newbie
Join Date: Apr 2006
Posts: 7
Rep Power: 0
![]() |
thnx for the help, could come in use later on. Ive checked out the net alaot but it seems this language lacks the capability to do what i want it to do...i thought it was the most extensive programming lang out there, oh well.
and yeah, my teachers are hell bent on the use of this lang.....cheap stuff u see. :s |
|
|
|
|
|
#8 |
|
Programmer
|
Ahem, why does everybody think the VB language sucks... its not the best in the world but you can do almost everyhting that other languages do, except a bit slower... but w/e. I've got what ya need
, here's the code ![]() Dim iCount As Integer
For iCount = 0 To List1.ListCount - 1
If (List1.Selected(iCount) = True) Then List1.RemoveItem (iCount): Exit Sub
Next iCount |
|
|
|
|
|
#9 |
|
Newbie
Join Date: Apr 2006
Posts: 7
Rep Power: 0
![]() |
Hmm,
thanks, but it doesnt seem to work, im guessing it wouldnt work for a list box using a row source would it? Still stuck there and have a few more hurdles to get over....assigning pics and stuff. Is that the reason then, coz i read somewhere that the row source would conflict with that code. Thanks really for the help. |
|
|
|
|
|
#10 |
|
Programmer
|
hrm.. what do you mean by a row source?
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|