Windows Develop Bookmark and Share   
 index > Windows Forms Designer > openFileDialog (help with Declaratoin) Thxs
 

openFileDialog (help with Declaratoin) Thxs

ok first off here is the C# Code i have:

private void button14_Click(object sender, EventArgs e)

Stream myStream  = null;

OpenFileDialog openFileDialog1 = new OpenFileDialog();

openFileDialog1.InitialDirectory = "c:\\";

openFileDialog1.Filter = "txt files (*.txt)|*.txt|All Files (*.*) | *.*";

openFileDialog1.FilterIndex = 2;

openFileDialog1.RestoreDirectory = true;

openFileDialog1.Title = "Load Client List";

openFileDialog1.FileName = "";

if (openFileDialog1.ShowDialog() == DialogResult.OK)

{

try

{

if ((myStream = openFileDialog1.OpenFile()) != null)

{

using (myStream)

{

//insert code to read the stream here

}

}

}

catch (Exception ex)

{

MessageBox.Show("Error: Could Not Read File error: " + ex.Message);

}

}

// F = Split(LTD, ":");

if (x < 1000)

listView1.ItemsIdea.SubItems[0] = F(0);

listView1.ItemsIdea.SubItems[1] = F(1);

Here is the VB6 Code:

Dim LTD As String, F As Variant, x As Integer

F = FreeFile
    With CommonDialog1
        .FileName = ""
        .DialogTitle = "Load Clients List"
        .Filter = "All Supported Types|*.txt"
        .ShowOpen
        If .FileName = "" Then Exit Sub
        Open .FileName For Input As #F
            While Not EOF(1)   // Realized I dont have that in my Code Above..lol
            Input #1, LTD
            F = Split(LTD, ":")
            If x < 1000 Then
            Set Item = ListView1.ListItems.Add(, , , , 2)
            Item.SubItems(1) = F(0)
            Item.SubItems(2) = F(1)
            x = x + 1
            ClientList.AddItem x

But that is what i'm Translating I can get most of it but some of it..The part i'm stuck on is:

F = FreeFile

Open .FileName For Input as #F

While Not EOF(1)

Input #1, LTD

F = Split(LTD, " : "

ListView1.View = lvwReport

So can someone help me Translate and insert that into the code i have at the Top of this Post...Thxs

PS: i have F Delared as a bool

public bool F;

I dont have a Clue on the ListView1.View = lvwReport  Totally drawing a blank on that part..lol
Rattlerr  Sunday, July 23, 2006 11:44 PM

There is no direct correlation with VB6 and C#. What exactly do you want this code to do, that it's not doing now ?

// ListView1.View = lvwReport

I would suspect that this is setting a listview to be in report mode. The setting is an enum in .NET, and I think the property may be different. But unless your listview changes modes, you can just declare it in the designer to have the right viewing mode.

cgraus  Monday, July 24, 2006 12:39 AM

I know theirs no Direct Correlation between vb6 and C#....I need to Translate the VB6 too .NET...I'm upgrading the VB6 Projects to .NET..

Thats what i need some help with...The Code i supplied I have already Translated from VB6 to .NET..Its just some of the VB6 Code i'm not sure how to Translate it into .NET..

Rattlerr  Monday, July 24, 2006 2:38 AM

So, to reiterate, what do you want this code to do that it isn't doing ?

cgraus  Monday, July 24, 2006 2:40 AM

Its not what its doing in VB6..The Point is to Upgrade to .NET,thats the whole point of migrating older App's to a new language..Thats what i'm doing...

I used that Convert tool VB6 to .NET and it does a sloppy job...

After the Conversion  from VB6 to .NET:

F = FreeFile  <--------VB6

F = FileSystem.FreeFile() <-----------  .NET upgrade "show a VisualBasic.FileSystem when you put the mouse over the text..

So now the job would be Translating that into C#..As for the LTD well its so Jumbled up like a jigsaw puzzle ,cant make head from tails...

 F = Split(LTD, ":") <---------- VB6 to .NET

the Semi - Colon is used in the Text file to Seperate the Username : Password 

 

Rattlerr  Monday, July 24, 2006 2:54 AM

I understand that, I was hoping you knew what functionality the code you're working on has. It looks to me like this code is just reading the entire file, putting a : between each line and then assigning the end result to a listbox. Given that there is no direct analog between the two, you can't convert it line by line. You need to work out what the code is doing, and rewrite it. Assuming I am right, which bit of that task are you stuck with ?

cgraus  Monday, July 24, 2006 3:09 AM

Converting this .NET Upgraded version using the Convert tool to C#..

F = FileSystem.FreeFile() <-----------  .NET upgrade "show a VisualBasic.FileSystem when you put the mouse over the text..Need that Converted to C#

The    F = Split(LTD, ":")  <---- A Requirement in the Text File  Username : Password if the StreamReader dosnt see the  Semi Colon it produces a Error..Its Reading the Text File and Loading the Username into the listview1,Showing a Offline Icon with the username...When the person press's the login in Button it logs their account into the system...The Text file is used as a Storage for the program to read from for the username and password...

 

 Dim LTD As String, F As Variant, x As Integer
    Set Header = ListView1.ColumnHeaders.Add(, , "", 250)
    Set Header = ListView1.ColumnHeaders.Add(, , "ClientID's", 1900)
    Set Header = ListView1.ColumnHeaders.Add(, , "", 0)
    F = FreeFile <--------------------------This giving me Trouble as mentioned Above
    With CommonDialog1
        .FileName = ""
        .DialogTitle = "Load Client List"
        .Filter = "All Supported Types|*.txt"
        .ShowOpen
        If .FileName = "" Then Exit Sub
        Open .FileName For Input As #F
            While Not EOF(1)
            Input #1, LTD<---------------This Line
            F = Split(LTD, ":") <-----------------------------And this Line
            If x < 1000 Then
            Set Item = ListView1.ListItems.Add(, , , , 2)
            Item.SubItems(1) = F(0)<----------- F is used here ..The (0) & (1) Represents Small Icons i have
            Item.SubItems(2) = F(1)

Rattlerr  Monday, July 24, 2006 3:27 AM

You can use google to search for other answers

Custom Search

More Threads

• Transparent TabControl
• 3 layers.
• PropertyGrid - Visible and Enabled Properties
• UserControl and Collections
• Designer Fails to Show From after VS 2003 Port - Problem Fixed!!!!!
• shaping windows forms in VB 05
• Hello World?
• VS2005 CryptographicException when adding SqlDataAdapter
• Register a UITypeEditor for all Controls
• Newbie IDesignerHost Question