Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

File txt con campi a lunghezza fissa

349 views
Skip to first unread message

ZZorro

unread,
May 24, 2010, 2:33:18 PM5/24/10
to
Salve a tutti,
dovrei creare un txt con un tracciato ben preciso, ovvero
,esempio: nome(lunghezza 30) , cognome(lunghezza 30) , iban
(lung. 27) , flag (1) , come posso creare delle variabili con
lunghezza in modo da creare poi il txt ?
In vb6 si metteva * lunghezza. Come fareste in net (2008)
grazie mille.
ZZorro
--
Postato da Virgilio Newsgroup: lo usi da web ma con le funzioni del newsreader http://newsgroup.virgilio.it
Gerarchie it, italia, it-alt, tin, it.binari. Unico!

VITRIOL

unread,
May 24, 2010, 3:02:33 PM5/24/10
to
Il 24/05/2010 20.33, ZZorro ha scritto:

> dovrei creare un txt con un tracciato ben preciso, ovvero
> ,esempio: nome(lunghezza 30) , cognome(lunghezza 30) , iban
> (lung. 27) , flag (1) , come posso creare delle variabili con
> lunghezza in modo da creare poi il txt ?

Potresti provare una cosa del genere:

Dim Nome As String = "Giuseppe"
Dim Cognome As String = "Garibaldi"
Using fs As New System.IO.StreamWriter("test.txt", True)
fs.WriteLine(Nome.PadRight(30))
fs.WriteLine(Cognome.PadRight(30))
End Using

--
news:it-alt.comp.software.openoffice : Il newsgroup dedicato a
OpenOffice.org, la suite open source di applicazioni per ufficio.
Scarica "OpenOffice.org 3.0 Soluzioni a raccolta", molto piᅵ di semplici
FAQ! http://it.openoffice.org/doc/manuali/

Andrea [Work]

unread,
May 25, 2010, 4:08:21 AM5/25/10
to
Il Mon, 24 May 2010 21:02:33 +0200, VITRIOL ha scritto:

> Potresti provare una cosa del genere:
>
> Dim Nome As String = "Giuseppe"
> Dim Cognome As String = "Garibaldi"
> Using fs As New System.IO.StreamWriter("test.txt", True)
> fs.WriteLine(Nome.PadRight(30))
> fs.WriteLine(Cognome.PadRight(30))
> End Using

Questo l'avete mai provato?

http://msdn.microsoft.com/it-it/library/x14b6s77(VS.90).aspx
Structure Person
Public ID As Integer
Public MonthlySalary As Decimal
Public LastReviewDate As Long
<VBFixedString(15)> Public FirstName As String
<VBFixedString(15)> Public LastName As String
<VBFixedString(15)> Public Title As String
<VBFixedString(150)> Public ReviewComments As String
End Structure

In lettura:
http://msdn.microsoft.com/it-it/library/microsoft.visualbasic.fileio.textfieldparser(VS.90).aspx

BlackSun

unread,
May 25, 2010, 8:14:28 AM5/25/10
to
Ciao,

> Questo l'avete mai provato?

> In lettura:http://msdn.microsoft.com/it-it/library/microsoft.visualbasic.fileio....

Dite che possa andar bene per analizzare i dati di un file csv?
Da alcune prove sembra che non dia problemi ma vorrei vostre opinioni
in merito.

Ciao BlackSun

Mario De Ghetto [MVP]

unread,
May 25, 2010, 3:00:40 PM5/25/10
to
> Questo l'avete mai provato?
>
> http://msdn.microsoft.com/it-it/library/x14b6s77(VS.90).aspx
> Structure Person
> Public ID As Integer
> Public MonthlySalary As Decimal
> Public LastReviewDate As Long
> <VBFixedString(15)> Public FirstName As String
> <VBFixedString(15)> Public LastName As String
> <VBFixedString(15)> Public Title As String
> <VBFixedString(150)> Public ReviewComments As String
> End Structure
>
> In lettura:
> http://msdn.microsoft.com/it-it/library/microsoft.visualbasic.fileio.textfieldparser(VS.90).aspx


Utilizza il namespace Microsoft.VisualBasic:
http://msdn.microsoft.com/it-it/library/x14b6s77(VS.90).aspx

Praticamente permette un workaround per lavorare come in VB6.
Da evitare.

--
Mario De Ghetto
Microsoft MVP - Visual Basic
http://deghetto.wordpress.com

0 new messages