open ascii file
-
if i have a ascii file, example: 2 4 3 40 42 56 etc... how to open this file? how to show this file in listview or datagrid? how to save in a ascii file if i have this data thank
This stuff is much nicer in C++, but in VB.NET you can still use the System.IO namespace to read and write files. In fact, a quick google will overload you with the information you need. Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
-
if i have a ascii file, example: 2 4 3 40 42 56 etc... how to open this file? how to show this file in listview or datagrid? how to save in a ascii file if i have this data thank
Use the following Code. Put an AsciiFile.txt with the data 2 4 3 40 42 56 in the applications path Imports System.IO Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents ListView1 As System.Windows.Forms.ListView Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.ListView1 = New System.Windows.Forms.ListView Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader Me.ColumnHeader2 = New System.Windows.Forms.ColumnHeader Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(200, 232) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" ' 'ListView1 ' Me.ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1, Me.ColumnHeader2}) Me.ListView1.Location = New System.Drawing.Point(8, 8) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size(264, 192) Me.ListView1.TabIndex = 1 Me.ListView1.View = System.Windows.Forms.View.Details ' 'ColumnHeader1 ' Me.ColumnHeader1.Width = 120 ' 'ColumnHeader2 ' Me.ColumnHeader2.Width = 135 ' 'Form1
-
Use the following Code. Put an AsciiFile.txt with the data 2 4 3 40 42 56 in the applications path Imports System.IO Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents ListView1 As System.Windows.Forms.ListView Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.ListView1 = New System.Windows.Forms.ListView Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader Me.ColumnHeader2 = New System.Windows.Forms.ColumnHeader Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(200, 232) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" ' 'ListView1 ' Me.ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1, Me.ColumnHeader2}) Me.ListView1.Location = New System.Drawing.Point(8, 8) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size(264, 192) Me.ListView1.TabIndex = 1 Me.ListView1.View = System.Windows.Forms.View.Details ' 'ColumnHeader1 ' Me.ColumnHeader1.Width = 120 ' 'ColumnHeader2 ' Me.ColumnHeader2.Width = 135 ' 'Form1
I think it's cool that you took the time to whip this up, but don't you think just the code that writes the file, along with a description of what it's doing, would be more helpful ? I personally thought that making the poster look for it themselves was more helpful again, given how elementary the question was. Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer