Example Code

Programmatically Populate Listbox Using Data from Text File

Code and Documents

Attachment

Download All

Overview
This example VI shows how to take a tab-delimited text file and use the contents of that file to populate a listbox on a LabVIEW front panel.


Description
This example shows how to take a tab-delimited text file and use the contents of that file to populate a listbox on a LabVIEW front panel. This VI gives the ability to Write to/ create a text file for testing purposes, then read the contents of that same file and populate a listbox with the tab-delimited items from the text file.

If you are writing to a new text file, notice the Written Text String indicator populate with the tab-delimited text that can be edited in the block diagram. If you are reading from a tab-delimited text file, notice the listbox populate with the items as well as the Read Text Array indicator.

 


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Download the attached folder to your computer
  2. Open the VI "Populate Listbox 2012 NIVerified.vi"
  3. Input the location and file name of the new text file and select the File Action control
  4. Run the program

 

Additional Information or References
VI Snippet

 Block Diagram.PNG

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Regards,
Austin S.

National Instruments
Academic Field Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Jandy
Member
Member
on

 

Kudos for providing example to create a list box from a text file.
 
Hello Austin, Wenjia,

Thanks very much for providing the example helping me to create  a list box from a text file.

But...

In the forum forums.ni.com/t5/Example-Programs, Programmatically Populate Listbox Using Data from Text File
Seems to have an error with one of the two files at the bottom.

Text refers to the VI Populate Listbox 2012 NIVerified.vi but link at bottom is 

 
 
   ,  which is the wrong VI.  Please fix it.
 
 Regards, John
rust
Member
Member
on

Thank you.