|
-
Aug 5th, 2006, 08:31 AM
#1
Thread Starter
Addicted Member
converting problem from VB6 to B NET 2005.
converting problem from VB6 to B NET 2005..
I have this code;
VB Code:
Private Sub List1_DoubleClick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles List1.DoubleClick
Dim fileName As String
If List1.Items.Count > 0 Then
'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"'
fileName = Dir(My.Application.Info.DirectoryPath & "\words\" & VB6.GetItemString(List1, List1.SelectedIndex) & "\")
List2.Items.Clear()
Do
If fileName = "" Then
Exit Do
Else
List2.Items.Insert(List2.Items.Count, fileName)
'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"'
fileName = Dir()
End If
Loop
Randomize()
List2.SelectedIndex = Rnd() * (List2.Items.Count - 1)
Text1.Text = VB6.GetItemString(List2, List2.SelectedIndex)
List2.Items.RemoveAt((List2.SelectedIndex))
End If
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...
-
Aug 5th, 2006, 10:58 AM
#2
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:
Dim Filename As String = My.Application.Info.DirectoryPath & "\words\" & ListBox1.SelectedItem.ToString & "\"
MessageBox.Show(Filename)
-
Aug 5th, 2006, 11:48 AM
#3
Fanatic Member
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.
-
Aug 5th, 2006, 02:38 PM
#4
Thread Starter
Addicted Member
-
Aug 5th, 2006, 03:19 PM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|