Solved

Combobox

Posted on 2003-11-04
7
410 Views
Last Modified: 2010-05-03
hi,

This is the problem.

When I delete a combobox item from then combobox list I get an empty rule in the text file where I save the combobox list
like

item1
item2
item3

so when I delete a item

"empty rule"
item2
item3

is there a way to delete the empty space so I don't get a empty rule because other code strand on a empty rule

***
When I press the delete button
this is on a form

Private Sub Command5_Click()
Dim piet As String
On Error GoTo fout
piet = Combo1.Text
Kill piet


If Combo1.ListCount = 0 Then Exit Sub
Combo1.RemoveItem (Combo1.ListIndex)
SaveCombo1
fout:
Exit Sub
End Sub

******
This is on a module

Public Sub SaveCombo1()

Open "naam" For Output As #1

For x = 1 To Form4.Combo1.ListCount
   Print #1, Form4.Combo1.List(x)
Next
Close #1
End Sub

thanks

Eric
0
Comment
Question by:klikklik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9677329
you need to open the file, then clear the file, then write into the file.
0
 
LVL 3

Accepted Solution

by:
NBrownoh earned 50 total points
ID: 9677333
oops, i dont think thats your problem, in the code

For x = 1 To Form4.Combo1.ListCount
   Print #1, Form4.Combo1.List(x)
Next

change it to

For x = 1 To Form4.Combo1.ListCount
   Tstr$ = Form4.Combo1.List(x)
   if Tstr$ <> "" then
     Print #1, Tstr$
   end if
Next
0
 
LVL 1

Expert Comment

by:Deshin13
ID: 9677340
Why dont you have a IF THEN ELSE before that???

If Piet = " " then
   exit sub
else
  piet = Combo1.Text
  Kill piet

   If Combo1.ListCount = 0 Then Exit Sub
   Combo1.RemoveItem (Combo1.ListIndex)
   SaveCombo1
end if

exit sub
fout:
Exit Sub

0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 76

Expert Comment

by:GrahamSkan
ID: 9677387
Change this line:
For x = 1 To Form4.Combo1.ListCount
to
For x = 0 To Form4.Combo1.ListCount - 1
0
 

Author Comment

by:klikklik
ID: 9677517
Thanks it works

If Piet = " " then
   exit sub
else
  piet = Combo1.Text
  Kill piet

was a try to del the empty string

but it works now

I hope that I can help YOU next time
eric
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9680087
dont forget to award the points
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9685010
cool, i didnt think i was the right answere, but thats cool.  getting 3900 expert points in 24 hours is pretty cool hehe, just started doing this almost 24 hours ago now.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question