Development Blog : C# Code Samples,.NET Tips and Tricks
Post con tag VB.NET
[VB.NET] : Popolare una DataTable con un file CVS
20 mar
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | Function ReadCSV(ByVal path As String) As System.Data.DataTable Dim sr As New StreamReader(path) Dim fullFileStr As String = sr.ReadToEnd() sr.Close() sr.Dispose() Dim lines As String() = fullFileStr.Split(ControlChars.Lf) Dim recs As New DataTable() Dim sArr As String() = lines(0).Split(","c) For Each s As String In sArr recs.Columns.Add(New DataColumn()) Next Dim row As DataRow Dim finalLine As String = "" For Each line As String In lines row = recs.NewRow() finalLine = line.Replace(Convert.ToString(ControlChars.Cr), "") row.ItemArray = finalLine.Split(","c) recs.Rows.Add(row) Next Return recs End Function |
[VB.NET] : Accesso in lettura ad una DataTable
20 mar
1 2 3 4 5 6 7 | Function ReadAccess(ByVal sqlString As String, ByVal path As String) As System.Data.DataTable Dim strConn As String = _"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path & ";" Dim recs As New Data.DataTable() DIm sql As New OleDbDataAdapter(sqlString, strConn) sql.Fill(recs) Return recs End Function |
[VB.NET] : Individuare tutte le stampanti installate
20 mar
1 2 3 4 5 6 7 | Protected Overrides Sub ChargeImpresoras() Dim lPrintDoc As New Printing.PrintDocument Dim lPrinter As Object For Each lPrinter In PrinterSettings.InstalledPrinters cboPrinters.Items.Add(lPrinter) Next End Sub |
VB.NET : Come Invertire una stringa
20 gen
Module RevString
Sub Main()
Dim inputString As String = Console.ReadLine()
ReverseOrder(inputString)
End Sub
Private Sub ReverseOrder(ByVal textInput As String)
Dim text2Rev As String = textInput
Dim reversed As String
Dim charArray() As Char = textInput.ToCharArray()
Array.Reverse(charArray)
reversed = charArray
Console.WriteLine(“”)
Console.WriteLine(“Testo originale: ” + text2Rev)
Console.WriteLine(“Testo invertito: ” + reversed)
End SubEnd Module
VB.NET : Come contare le linee di un richtextbox
20 gen
private sub countlines(byval rtb as richtextbox) dim count as string count = rtb.lines.count msgbox(count) end sub