Solved

Combobox

Posted on 2003-11-04
7
402 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
Windows 10 start screen issues 9 62
Best way to parse out a json string in VB6? 10 291
vb6 connector to mongodb 2 141
How to compare ms sql hashbytes results within vb6 5 98
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

726 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