Results 1 to 5 of 5

Thread: converting problem from VB6 to B NET 2005.

  1. #1

    Thread Starter
    Addicted Member noam309's Avatar
    Join Date
    Aug 2006
    Posts
    225

    converting problem from VB6 to B NET 2005.

    converting problem from VB6 to B NET 2005..

    I have this code;
    VB Code:
    1. Private Sub List1_DoubleClick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles List1.DoubleClick
    2.         Dim fileName As String
    3.         If List1.Items.Count > 0 Then
    4.             'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
    5.             fileName = Dir(My.Application.Info.DirectoryPath & "\words\" & VB6.GetItemString(List1, List1.SelectedIndex) & "\")
    6.             List2.Items.Clear()
    7.             Do
    8.                 If fileName = "" Then
    9.                     Exit Do
    10.                 Else
    11.                     List2.Items.Insert(List2.Items.Count, fileName)
    12.                     'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
    13.                     fileName = Dir()
    14.                 End If
    15.             Loop
    16.             Randomize()
    17.             List2.SelectedIndex = Rnd() * (List2.Items.Count - 1)
    18.             Text1.Text = VB6.GetItemString(List2, List2.SelectedIndex)
    19.             List2.Items.RemoveAt((List2.SelectedIndex))
    20.         End If
    21.     End Sub

    and I got this message as it seen here :
    'UPGRADE_WARNING: Dir has a new behavior
    I dont know how to fix this problem but:

    I have a txt file and two words each sentence , and the program should display one word from a sentence randomly in a textbox and the user has two write the answer and if it good he will get a point in a labeltext if not a point in no good labeltext. suppose to be very simple but in VB 6 I have done it very good and now in NET 2005 have some problem can anyone can help me in such a code made in VB NET 2005 another thing that it should be in the code the whole the words from the txt file should be load into a list box at form load and after an answer made by the user , the word deleted from the listbox and the user can see the ramaining words in it.
    please help me with this code or just give me a start of code that I could get the first value of a text and second one and random them ..
    I want to make my dictation program as I already made by VB6
    thanks in advance...

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: converting problem from VB6 to B NET 2005.

    Just remove the Dir call and use the Listbox .SelectedItem property in order to get the value that is selected...
    VB Code:
    1. Dim Filename As String = My.Application.Info.DirectoryPath & "\words\" & ListBox1.SelectedItem.ToString & "\"
    2. MessageBox.Show(Filename)

  3. #3
    Fanatic Member dom_stapleton's Avatar
    Join Date
    Sep 2005
    Location
    Leigh-on-Sea, UK
    Posts
    665

    Re: converting problem from VB6 to B NET 2005.

    Although it may seem like a huge task, it is sometimes far easy to rebuild your projects from scratch when you upgrade from VB 6.
    I use Microsoft Visual Basic 2008 Express Edition.

    If my post has been helpful, please rate it, unless you don't believe in Karma... which actually I don't!

    Resources:
    Visual Basic Tutorials (1, 2) | MSDN Library | Google | Krugle | Search Forums

    Free components:
    Windows Forms Components | XP Common Controls Library

  4. #4

    Thread Starter
    Addicted Member noam309's Avatar
    Join Date
    Aug 2006
    Posts
    225

    Re: converting problem from VB6 to B NET 2005.

    Indeed its a huge task to do so:
    So please I have a question for you-

    I need just a little code in vb net 2005 to begin my application (it will give me a good start so please help...

    I have a text file (words.txt) , and there I have a lot of sentences with two words each one, I just want a code which will pick randomly one sentence and display the result in 2 textboxes I have in the application,
    it is realy dont complicate in VB6 but I need this code in VB NET 2005

    please it would be very helpfull!!!!!

  5. #5
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: converting problem from VB6 to B NET 2005.

    Just look up StreamReader in this forum, you should pull several examples, as reading text from a file is a common question. In particular, the .ReadLine method is used to read a line of text, then its just a matter of splitting the string or using some other sort of string manipulation in order to display the two different values in the line...

    Alternatively, you can read the entire file one time into a string array, and then just access the string array in order to display or manipulate the line you want, so you dont have to read the file each time you wish to display something...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width