Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 18th, 2006, 12:12 PM   #1
SMJH
Newbie
 
Join Date: Apr 2006
Posts: 7
Rep Power: 0 SMJH is on a distinguished road
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.
SMJH is offline   Reply With Quote
Old Apr 18th, 2006, 2:07 PM   #2
zorin
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 218
Rep Power: 4 zorin is on a distinguished road
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 = ""
and
Text2.text = ""
will be the text boxes that you want to clear and the
List1.Clear
and
List2.Clear
will clear the text boxes that you want to clear.

So basically just customise those four lines of code to the Items that you want to use them for.
zorin is offline   Reply With Quote
Old Apr 18th, 2006, 2:59 PM   #3
SMJH
Newbie
 
Join Date: Apr 2006
Posts: 7
Rep Power: 0 SMJH is on a distinguished road
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.
SMJH is offline   Reply With Quote
Old Apr 18th, 2006, 3:41 PM   #4
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
You can host images at www.imageshack.us
Polyphemus_ is offline   Reply With Quote
Old Apr 18th, 2006, 7:42 PM   #5
SMJH
Newbie
 
Join Date: Apr 2006
Posts: 7
Rep Power: 0 SMJH is on a distinguished road
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.
SMJH is offline   Reply With Quote
Old Apr 19th, 2006, 1:12 PM   #6
zorin
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 218
Rep Power: 4 zorin is on a distinguished road
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()
and your items will look sonthing like this
 List1.AddItem ("you Information here")
 List1.AddItem ("you Information here again")
Then you would place this code behined your "<<Remove" button that I can see in your picture.
List1.RemoveItem (0)
Now if you have managed to do that and your program runs you are now able to select somthing in the list box and when you press the remove button that item will be removed. There is just one problem though, if you chose somthing like the 3rd item on the list and press your "<<Remove" button the Item at the top of your list disappears >_<

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)
the number "6" being the sixth item on the list. If you wanted to remove the 4th Item in your list box it would be the same but with the number that the Item appears in your list.
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.
zorin is offline   Reply With Quote
Old Apr 19th, 2006, 4:52 PM   #7
SMJH
Newbie
 
Join Date: Apr 2006
Posts: 7
Rep Power: 0 SMJH is on a distinguished road
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
SMJH is offline   Reply With Quote
Old Apr 20th, 2006, 2:35 AM   #8
brownhead
Programmer
 
Join Date: Mar 2006
Location: California
Posts: 37
Rep Power: 0 brownhead is on a distinguished road
Send a message via AIM to brownhead Send a message via MSN to brownhead
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
brownhead is offline   Reply With Quote
Old Apr 23rd, 2006, 12:55 PM   #9
SMJH
Newbie
 
Join Date: Apr 2006
Posts: 7
Rep Power: 0 SMJH is on a distinguished road
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.
SMJH is offline   Reply With Quote
Old Apr 23rd, 2006, 6:49 PM   #10
brownhead
Programmer
 
Join Date: Mar 2006
Location: California
Posts: 37
Rep Power: 0 brownhead is on a distinguished road
Send a message via AIM to brownhead Send a message via MSN to brownhead
hrm.. what do you mean by a row source?
brownhead is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:24 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC