|
Always good when you solve your own issue; even better when you post the solution.
|
|
|
|
|
I stumbled on the answer by accident, fixing something else after the post. The old I could of had a V8 Juice
|
|
|
|
|
Dim directory = "c:\yeni"
Dim dosyalar() As System.IO.FileInfo
Dim dirinfo As New System.IO.DirectoryInfo(directory)
dosyalar = dirinfo.GetFiles("*", IO.SearchOption.AllDirectories)
For Each dosya In dosyalar
ListBox1.Items.Add(dosya)
i get directory info and fileinfo there are 2 csv files in folder
the i copy it to
Dim parser As New FileIO.TextFieldParser(dosyalar)
it doest go to parse function
|
|
|
|
|
sensizbenlik wrote: it doest go to parse function
It might be going out back for a smoke. I suspect that the debugger will tell you for sure.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
You really should go read the documentation for the classes that you are trying to use. None of the overloads for the TextFieldParser constructor take an array of System.IO.FileInfo objects.
|
|
|
|
|
i do it
For Each f As FileInfo In dosyalar
Dim parser As New FileIO.TextFieldParser(f.FullName)
|
|
|
|
|
Okay.... and then what happened?
It would really help speed things along if you just tell us what it is that your code is doing. We can't see your code or your screen to know what is going on. It would also help if you posted your real code.
|
|
|
|
|
when clicking the button code is getting all csv files from the folder to database. in the folder csv files have 3 columns. but contents are different
|
|
|
|
|
Well considering that I have no idea what CSV files you are talking about, what database you are talking about or what
sensizbenlik wrote: but contents are different
means and since you do not provide the information required to help, I am at a loss as to what you expect people to do for you.
|
|
|
|
|
Hi,
I've been searching for some examples of TCP client application. The setup is not a regular server/client.
I've a serial to ethernet converter (Moxa or Ewon device) which act like a server. The device is sending data on an independant time base. I need to grab that data and analyze it. I can open the connection on a particular port, but don't know how to receive the data.
Somebody can give some advise.
Thx,
Kurt
|
|
|
|
|
|
I am currently working on a project to exchange data by using a web service. Do work with the web service, the owner of the web service has given me a WSDL file. However, when I read-in this file in Visual Studio 2010 as a service reference, then no routines are created in the Reference.vb. In other situations that I used a WSDL file and added it as a service reference, that was the case. Can anyone give me advice on how I can use this WSDL to exchange data with the web service? I am using VB.NET to make the connection.
|
|
|
|
|
Again, I have a question on my homework this week. When I run my code, it doesn't list the races/results in order. What am I doing wrong?
Dim chevy(8) As Decimal
Dim ford(8) As Decimal
Dim chevyCount As Integer = 0
Dim fordCount As Integer = 0
Dim index As Integer = 0
For index = 0 To 7
Console.WriteLine("Enter Chevy " & (index + 1) & " : ")
chevy(index) = Console.ReadLine()
Next
Console.ReadLine()
For index = 0 To 7
Console.WriteLine("Enter Ford " & (index + 1) & " : ")
ford(index) = Console.ReadLine()
Next
Console.ReadLine()
For index = 0 To 7
If (chevy(index) < ford(index)) Then
chevyCount = chevyCount + 1
Console.WriteLine("Chevy won by " & ford(index) - chevy(index) & " . ")
Console.WriteLine("Chevy has won " & chevyCount & " races.")
End If
Next
For index = 0 To 7
If (chevy(index) > ford(index)) Then
fordCount = fordCount + 1
Console.WriteLine("Ford won by " & chevy(index) - ford(index) & " . ")
Console.WriteLine("Ford has won " & fordCount & " races.")
End If
Next
For index = 0 To 7
If (chevy(index) = ford(index)) Then
chevyCount = fordCount
Console.WriteLine("This race was a tie!")
End If
Next
Console.ReadLine()
If chevyCount > fordCount Then
Console.WriteLine("Chevy wins the match!")
Else
Console.WriteLine("Ford wins the match!")
End If
Console.ReadLine()
End Sub
|
|
|
|
|
Member 10728667 wrote: it doesn't list the races/results in order
You are going to explain what it is that you mean. Of course it lists them in order. It would really help us if you gave some idea of the input that you used, the output that you got and why the output is not what you expected it to be. Quite frankly without knowing what it is that you are trying to do here, it's really hard to figure out. But I can tell you that your code is doing exactly what you told it to do.
|
|
|
|
|
I have taken a quick look:
1. change those
Console.ReadLine()
after every Next's to
Console.WriteLine()
2. There is a logical error here, find and fix it yourself:
For index = 0 To 7
If (chevy(index) < ford(index)) Then
chevyCount = chevyCount + 1
Console.WriteLine("Chevy won by " & ford(index) - chevy(index) & " . ")
Console.WriteLine("Chevy has won " & chevyCount & " races.")
End If
Next
3. You have missed out one more condition in:
If chevyCount > fordCount Then
Console.WriteLine("Chevy wins the match!")
Else
Console.WriteLine("Ford wins the match!")
End If discover and add it yourself.
|
|
|
|
|
I am a high school student taking an online Computer Programming class. Using Visual Basic 2010 ver 4, I have to create a form with 2 text boxes and 2 buttons. 1 button will swap the text in the boxes and the other will close the form. I have the "close the form" button but I simply can not figure out how to code the swap button. Can anyone please help?
Thank you so much for your help.
Chase
|
|
|
|
|
Well it's not a big secret.
Declare a string variable
Assign the first text box text to your string variable
Assign the content of the first text box to the text of the second text box.
Assign the second text box text to the value that you stored in your string variable.
You should be able to figure it out. Give it a try.
modified 12-Apr-14 19:58pm.
|
|
|
|
|
1. Thank you for being honest about why you need help.
2. Basic concept is:
when swap button pushed
save text of 'A' box in local variable
set 'A' box text to contents of 'B'
set 'B' to value in local variable
If you need further help, post the code you are using.
Tim
|
|
|
|
|
Thank you for responding. This is my code:
Dim A As Char
A = TextBox1.Text
TextBox1.Text = TextBox2.Text
TextBox2.Text = String.Format("{A}", TextBox2.Text)
When I try to debug and enter in values it tells me "FormatException was unhandled."
Thank you again for your help. I don't know why I can't understand how to do this.
Chase
|
|
|
|
|
The variable A should be a string type. Also your String.Format statement is incorrect, but also unnecessary. Try
Dim tempStr As String
tempStr = TextBox1.Text
TextBox1.Text = TextBox2.Text
TextBox2.Text = tempStr
|
|
|
|
|
This might be a little late but still good for educational value.
All the suggestions are perfectly correct and easy to read when inspecting the code.
However there is one other way of doing this without declaring any additional variables like:
Dim txtA as string
Dim txtB as string
Each control has a "Tag" property that you can use to store any type of text.
Therefore you can write the following code without declaring any additional variables.
In your "Form_Load"
txtA.Tag = txtA.text
txtB.Tag = txtB.text
In the Button_Click event of the Swop Button you write:
txtA.text = txtB.Tag
txtB.text = txtB.Tag
The "Tag" property has many uses, this is but one possible use to keep from declaring too many variables for silly little tasks while you have other places to store relevant data.
Regard,
Tino
"Plan your work, Work your plan"
|
|
|
|
|
Imports System.IO
Imports System.IO.File
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim table As New DataTable
table.Columns.Add("ZipCode")
table.Columns.Add("State")
table.Columns.Add("City")
Dim parser As New FileIO.TextFieldParser("C//:test.csv") >>>>>>>> the program is running i can import test.csv file but in c: drive i want any .csv file import to the program ("c://*.csv) command is not runnig. pls help can u give me an example??
parser.Delimiters = New String() {";"}
parser.HasFieldsEnclosedInQuotes = True
parser.TrimWhiteSpace = True
parser.ReadLine()
Do Until parser.EndOfData = True
table.Rows.Add(parser.ReadFields())
Loop
Dim Sql As String = "INSERT INTO tblZipCode (ZipCode,State,City) VALUES (@ZipCode,@State,@City)"
Dim SqlconnectionString As String = "Data Source=(localdb)\Projects;Initial Catalog=srkn;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;"
Using connection As New SqlClient.SqlConnection(SqlconnectionString)
Dim cmd As New SqlClient.SqlCommand(Sql, connection) ' create command objects and add parameters
With cmd.Parameters
.Add("@ZipCode", SqlDbType.VarChar, 15, "ZipCode")
.Add("@State", SqlDbType.VarChar, 20, "State")
.Add("@City", SqlDbType.VarChar, 30, "City")
End With
Dim adapter As New SqlClient.SqlDataAdapter()
adapter.InsertCommand = cmd
'--Update the original SQL table from the datatable
Dim iRowsInserted As Int32 = _
adapter.Update(table)
End Using
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
|
|
|
|
|
sensizbenlik wrote: can u give me an example
If you had gone and looked at the DirectoryInfo Class[^] just like you was told to here[^] you would have found the DirectoryInfo.GetFiles[^] method that provides you an example for what you want to do.
|
|
|
|
|
Do some research, you have been given the pointers to where to look. No one is going to write your code for you...
Here is some pseudo code. Split the parsing code into a new method.
get the directory info
for each of the fileinfo in the directoryinfo
pass the fileinfo to the parsing function.
Now go write your code.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hello
Dim parser As New FileIO.TextFieldParser("c://test.csv")
i can import a csv file like this code
but
i want to import all csv files in c: driver to database
Dim parser As New FileIO.TextFieldParser("c://*.csv")is not working
pls help
|
|
|
|