|
Can somebody help me with this code. I need a VB.net equivanlent.
string fn = @"c:\temp\data.txt";<br />
using (System.IO.StreamReader sr = new System.IO.StreamReader(fn))<br />
{<br />
for (int row = this.c1FlexGrid1.Rows.Fixed; sr.EndOfStream == false; <br />
row++)<br />
{<br />
string line = sr.ReadLine();<br />
<br />
if (row >= this.c1FlexGrid1.Rows.Count)<br />
this.c1FlexGrid1.Rows.Count++;<br />
<br />
int col = this.c1FlexGrid1.Cols.Fixed;<br />
string[] cells = line.Split(' ');<br />
for (int c = 0; c < cells.Length; c++)<br />
{<br />
if (col >= this.c1FlexGrid1.Cols.Count)<br />
this.c1FlexGrid1.Cols.Count++;<br />
this.c1FlexGrid1[row, col] = cells[c];<br />
col++;<br />
}}<br />
} <br />
I need the loops mainly
Thanks
-- modified at 21:10 Sunday 28th January, 2007
|
|
|
|
|
Which bit are you stuck on ? I don't think VB.NET supports 'using', that just means you create the object, and call Dispose at the end of your code block.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I mainly need the loops
-- modified at 21:24 Sunday 28th January, 2007
|
|
|
|
|
Let me see how I go...
Dim row as int =
this.c1FlexGrid1.Rows.Fixed;<br />
<br />
while (sr.EndOfStream = false)<br />
<br />
dim line as string = sr.ReadLine()<br />
<br />
<br />
if (row >= c1FlexGrid1.Rows.Count) then<br />
c1FlexGrid1.Rows.Count++<br />
<br />
dim col as int = c1FlexGrid1.Cols.Fixed<br />
<br />
dim cells as string() = line.Split(' ')<br />
<br />
dim c as int<br />
<br />
for c = 0 to cells.Length<br />
<br />
if col >= c1FlexGrid1.Cols.Count then<br />
c1FlexGrid1.Cols.Count++<br />
<br />
c1FlexGrid1(row, col) = cells(c);<br />
col++;<br />
end for
<br />
row = row + 1<br />
<br />
end while<br />
<br />
A bit of a guess, but I'd say this is more suited to the while loop anyhow.<br />
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Thanks Chris I'll give it a try.
|
|
|
|
|
Ooops - I left a 'this'. this is me in VB.NET. As in me.Invalidate() - isn't it just the cutest thing ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
VB does have a 'using' equivalent. The equivalent VB is the following produced with Instant VB - note that the inner loop could have been converted to a VB 'For' loop instead as Christian's post indicated:
Dim fn As String = "c:\temp\data.txt"
Using sr As System.IO.StreamReader = New System.IO.StreamReader(fn)
Dim row As Integer = Me.c1FlexGrid1.Rows.Fixed
Do While sr.EndOfStream = False
Dim line As String = sr.ReadLine()
If row >= Me.c1FlexGrid1.Rows.Count Then
Me.c1FlexGrid1.Rows.Count += 1
End If
Dim col As Integer = Me.c1FlexGrid1.Cols.Fixed
Dim cells As String() = line.Split(" "c)
Dim c As Integer = 0
Do While c < cells.Length
If col >= Me.c1FlexGrid1.Cols.Count Then
Me.c1FlexGrid1.Cols.Count += 1
End If
Me.c1FlexGrid1(row, col) = cells(c)
col += 1
c += 1
Loop
row += 1
Loop
End Using
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: C# to Python converter, VB to Python converter
|
|
|
|
|
I've been saving my datatables with .writexml
However, sometimes I create a dataview from the datatable and then allow the user to filter the dataview.
But now I want to save the filtered data back to .xml
How can I get the dataview back into the datatable? Do I have to go row by row?
Thanks in advance, as always
|
|
|
|
|
Hello guys
i have a client wich connects to multiple servers in the background of an application
I just want to show the user to wich server the client is connected each time
means : how can i do a real time modification to the form ?
Ex : client connected to server 1
Dispaly in form1 . You are connected to Server 1
EX : client connected to server 2
Dispaly in form1 . You are connected to Server 2
Regards
Ramy
|
|
|
|
|
Use a thread class that allows sending information to the main thread, and use that to display your status.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
thx for answering
Any help,or any Link for that?
Note .I am a bit new in vb.net, and totally new in threading
Regards
Ramy
|
|
|
|
|
It there some sort of test to see if you are in design time for VB.Net? I am having a problem where I need a bit of code to be executed at run time...but it is going to be invalid in my control at design time
Using theAdaptor As New DSEmployeeNamesTableAdapters.GetAllEmployeeNamesTableAdapter
DsEmployeeNames1.Merge(theAdaptor.GetData(Common.CurCompany.ID))
End Using
At design time 'Common.CurCompany.ID' has not yet been set, but at runtime it will be valid...any suggestions? Maybe a preprocessor symbol I could use to pass to
<Diagnostics.Conditional("")>?
Thanks ahead of time for any help
-- modified at 15:57 Sunday 28th January, 2007
Pablo
while(1){DoTheDo();}
|
|
|
|
|
Yes, it's DesignMode, from memory. It doesn't always work. The new designer sucks.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Perfect, thanks a lot
Pablo
while(1){DoTheDo();}
|
|
|
|
|
I winder if there is a way to send SMS via MAPI
I need som hints and VB-code to a litle program I'm working on...
Totte
|
|
|
|
|
hi,
wat will be the code for populating the combobox. suppose Customername is a field of the Customer table, how can i populate the combobox with that field name? Pls help me to find out this problem.
SS
|
|
|
|
|
Set the datasource to be your datatable, then set the DisplayMember property to be 'Customername'
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
help please on how to process command line arguments that being pass to the application..
|
|
|
|
|
They are generally passed as a string array to your program's entry point, although it wouldn't surprise me to find they are also a property of the Application object.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Sir/madam,
I am using access database.I have applied password to the database.Now , I wanted to make the connection string.Presently , i am using the .udl file to make the connection string and in the udl file , in the case of choosing the provider, i am using Microsoft Jet 4.0 OLE DB Provider.and after then i am comming to the connection tab.There i am facing the following error after typing the password and clicking the test connection button.
Test connection failed because of an error in initializing the provider.Cannot start ur application.The workgroup information file is mising or opened exclusively by another user.
But , I have closed the database and even i have restarted my machine.But i am encountering the same problem.
Please help in making the connection string when i have applied the password.
Thanks and Regards
Pankaj
|
|
|
|
|
I didn't really read all of your post, it really get tiresome when you make every other word bold, but here is page where you can see examples of connection strings:
www.connectionstrings.com[^]
---
Year happy = new Year(2007);
|
|
|
|
|
Try to create user's account with the password you are using for connection string
jaakinye
|
|
|
|
|
Sir/Madam,
I have a table , having two fields , first for name and second for roll number.I don't have serial number field in that table.Can , I display Serial number field in the datagridview , with those two fields.
I mean if i have ten records in the table. Then datagrid should display record no for each row, like for first row it should display 1 , and for second row , there should display 2 and so on.This should happen in the extra column in the datagridview.Is it possible.
Please help.
Thanks and regards
Pankaj
|
|
|
|
|
Hi,
You can use sql query in this case. If your current sql query is -
select name,rollno from students
Then modify the query as -
select 0 as [Serial No.],name, rollno from students.
This modified query will generate a column named Serial No. whoes rows will be filled by 0. Then in the program use a counter to count the rows, in the RowDataBound event handler. Replace the text in column 0 with the counter value. You will get your desired resutls.
Hope i am clear enough.
I am assuming that you are using SQL Server as database.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Sir/madam,
I am facing problem in the crystal reports.Now , Suppose I have 20 records into the database(each record contain one field for name).I am able to display them in the reports in the vertical order , to get the print outs .But the problem is , I am not able to display these 20 records in two column.Two columns means , First column has ten records and second column has 10 records.Actually , the purpose of using two columns is , I want to save the page . I want to put the names on the envelope , after getting the print out , I will cut those names from page and finally will be pasted on the envelope.Is there any option to do this task.Hope , I am trying to make u understand my problem.
Please help.
Thanks and regards
Pankaj
|
|
|
|