Vb.Net CVS Dasya Oluşturma & İçine yazma

Samet ÖZMANAv Samet ÖZMANAv

23 Temmuz 2021 Yazılım Dilleri (151) /Visual Basic .Net (5) (28)

Vb.Net CVS Dasya Oluşturma & İçine yazma

Paylaşmak güzeldir. Lütfen sizde paylaşın...


'//////////////////////////////////////////////////////////////////////////////////////////////////////
'////Uygulama :Cvs File Create//////////////////////////////////////////////////////////////////
'////Tarih:12.04.2018//////////////////////////////////////////////////////////////////////////////////
'////Yazar:Samet ÖZMANAV///////////////////////////////////////////////////////////////////////////////
'//////////////////////////////////////////////////////////////////////////////////////////////////////

Imports Microsoft.VisualBasic.FileIO
Public Class Create
Private Sub CreateCSVfile(ByVal _strCustomerCSVPath As String, ByVal _CustomerID As String, ByVal _FirstName As String, ByVal _LastName As String, ByVal _Phone As String, ByVal _Email As String, ByVal _Msg As String)
Try
Dim stLine As String = ""
Dim objWriter As IO.StreamWriter = IO.File.AppendText(_strCustomerCSVPath)
If IO.File.Exists(_strCustomerCSVPath) Then
objWriter.Write(_CustomerID & ",")
objWriter.Write(_FirstName & ",")
objWriter.Write(_LastName & ",")
objWriter.Write(_Email & ",")
'If value contains comma in the value then you have to perform this opertions
Dim append = If(_Msg.Contains(","), String.Format("""{0}""", _Msg), _Msg)
stLine = String.Format("{0}{1},", stLine, append)
objWriter.Write(stLine)
objWriter.Write(_Phone)
objWriter.Write(Environment.NewLine)
End If
objWriter.Close()
ClearTextbox()
Catch ex As Exception
End Try
End Sub
Private Sub ClearTextbox()
txtCustomerId.Text = ""
txtFirstName.Text = ""
txtLastName.Text = ""
txtPhoneNo.Text = ""
txtEmail.Text = ""
txtMessage.Text = ""
End Sub
Private Sub btnView_Click(sender As Object, e As EventArgs)
'Read.Show()
End Sub
Private Sub BtnSubmit_Click(sender As Object, e As EventArgs) Handles BtnSubmit.Click
CreateCSVfile(Application.StartupPath & "\" & "CustomerRecords.csv", txtCustomerId.Text.ToString(), txtFirstName.Text.ToString(), txtLastName.Text.ToString(), txtPhoneNo.Text.ToString(), txtEmail.Text.ToString(), txtMessage.Text.ToString())
MsgBox("Finally Processing ..", vbInformation, "Create Cvs File")
End Sub
End Class


Paylaşmak güzeldir. Lütfen sizde paylaşın...



Herkesyazar Ara