Solved

Combobox

Posted on 2003-11-04
7
378 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 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now