🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: be.comp.programming
2 messages
2 total messages Started by MdV Mon, 30 Jun 2003 09:15
TXT bestand in VB
#4899
Author: MdV
Date: Mon, 30 Jun 2003 09:15
2 lines
1150 bytes
Hoi, hoe kan ik de inhoud van een txtfile (onwillekeurige hoeveelheid items)
importeren in een combobox ?
Re: TXT bestand in VB
#4904
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads