Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Combobox

Posted on 2003-11-04
7
Medium Priority
?
428 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
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 200 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
Industry Leaders: 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!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

824 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