🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #4904

Re: TXT bestand in VB

#4904
From: sotto
Date: Mon, 30 Jun 2003 11:35
32 lines
2212 bytes
On Mon, 30 Jun 2003 09:15:10 +0000, MdV wrote:

> Hoi, hoe kan ik de inhoud van een txtfile (onwillekeurige hoeveelheid
> items) importeren in een combobox ?

Deze twee routines komen (lichtelijk gewijzigd) uit programming visual basic 6.0 (microsoft
press) geschreven door Francesco Balena en ik vind ze bijzonder handig om
 om te gebruiken:

in uw form_load zet ge bijvoorbeeld:
call txttocombobox(Combobox1,"foobar.txt")
en eronder of erboven:

function readtextfile(filename as string) as string
  dim fnum as integer, isopen as boolean
  on error goto eh
  fnum = freefile()
  open filename for input as #fnum
  isopen = true
  readtextfile = input(LOF(fnum), fnum)
eh:
  if isopen then close #fnum
  if err then err.reaise err.number,,err.description
end function

sub txttocombobox(cmb as combobox, filename as string)
  dim items() as string, i as long
  items = split(readtextfile(filename), vbcrlf)
  for i = lbound(items) to ubound(items)
    if len(items(i)) > 0 then cmb.additem items(i)
  next
end sub
Technical Details
Message-ID: <pan.2003.06.30.11.35.54.649259@sotto.be>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!elnk-pas-nf2!elnk-pas-nf1!newsfeed.earthlink.net!west.cox.net!east.cox.net!peer02.cox.net!cox.net!ecngs!feeder.ecngs.de!feed1.news.be.easynet.net!news.be.wanadoo.com!news.wanadoo.be!not-for-mail
References: <ycTLa.5815$P26.5800@afrodite.telenet-ops.be>

Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit
X-Google-Thread: fcea4,e702927ea214b8a3
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2003-06-30 04:36:09 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!elnk-pas-nf2!elnk-pas-nf1!newsfeed.earthlink.net!west.cox.net!east.cox.net!peer02.cox.net!cox.net!ecngs!feeder.ecngs.de!feed1.news.be.easynet.net!news.be.wanadoo.com!news.wanadoo.be!not-for-mail
From: "sotto" <junk@sotto.be>
Newsgroups: be.comp.programming
Subject: Re: TXT bestand in VB
Date: Mon, 30 Jun 2003 13:35:58 +0200
Organization: Wanadoo Belgium
Lines: 34
Message-ID: <pan.2003.06.30.11.35.54.649259@sotto.be>
References: <ycTLa.5815$P26.5800@afrodite.telenet-ops.be>
NNTP-Posting-Host: adsl-144-56.wanadoo.be
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: sinclair.be.wanadoo.com 1056972958 1535357 213.177.144.56 (30 Jun 2003 11:35:58 GMT)
X-Complaints-To: abuse@wanadoo.be
NNTP-Posting-Date: Mon, 30 Jun 2003 11:35:58 +0000 (UTC)
User-Agent: Pan/0.13.3 (That cat's something I can't explain)