|
-
Mar 31st, 2004, 10:13 AM
#1
Thread Starter
Fanatic Member
Migrating from VB6 to VB.Net
Nobody likes VB.Net at first instance. VB6 programmers, who just migrate to VB.Net keep on cursing themseleves for migrating, as they miss so many useful things in VB6 (like control array, shortcut keys in property window, etc). But later on they are pleased when they are aware of the strength of VB.Net.
Now, as the VB.Net community is growing faster and even www.vbforums.com has a seperate section with more than 10K threads as on date, here's an attempt to share our experience while migrating from VB6 to VB.Net.
I hereby request you to share your problem(s) and solution(s) during the migration. I also hereby request the moderator of this site to make this thread sticky for sometime so that the users are aware of the same.
So... who's the first to post?
Regards,
Prakash
-
Mar 31st, 2004, 10:20 AM
#2
Thread Starter
Fanatic Member
Here's the first one. Well, its basic thing. But could be useful for someone.
I wanted to show a form 'Form1' in my project from my Sub Main. I used the following code.
VB Code:
Sub Main
Form1.Show
End Sub
The code doesn't work. So the solution is...
Declare a new instance of the form
Then display the form.
VB Code:
frmMain.ShowDialogue
'Or
Application.Run("frmMain")
-
Apr 2nd, 2004, 09:39 AM
#3
Thread Starter
Fanatic Member
No one yet to contribute??
-
Apr 3rd, 2004, 08:33 AM
#4
Member
I'll try!
Vb.net - no control arrays! Very sad... 
The solution: Something else!
instead of simply using design view to create control arrays you do the following:
VB Code:
Const N = 4
Private mytextboxes() As TextBox
Private Sub CreateMyTextBoxes()
ReDim mytextboxes(N)
Dim i As Short
For i = 1 To N
mytextboxes(i) = New TextBox
With mytextboxes(i)
.name = "TB" & i
.tag = i
.location = New Point(50 + i * 50, 20 + i * 20)
End With
Me.controls.add(mytextboxes(i)) 'Add to the form
AddHandler mytextboxes(i).TextChanged, AddressOf SomeSub 'Add the event to some sub
Next
End Sub
Private Sub SomeSub(ByVal sender As System.Object, ByVal e As System.EventArgs)
messagebox.show("Textbox " & sender.tag & " changed!")
End Sub
That's it!
EDIT:syntax glitches fixed
Last edited by SnappleBoy; Apr 3rd, 2004 at 10:18 AM.
i like my icon, made it myself...
except for Buttercap of course.
and for the symbol in the back that is copied from Slipknot...
I like the icon i use but isn't really mine.
-
Apr 3rd, 2004, 09:00 AM
#5
Fanatic Member
So how do you make the above work? Do you have an actual example in a zip file?
I was just experiencing this issue in VB6 migrating to VB.NET. The issue of Control Arrays that is.
Thanks!
-
Apr 3rd, 2004, 10:20 AM
#6
Member
Actually that's it!
Just copy paste the above code(Now proprly cased and tested)
and call the CreateMyTextBoxes() whenever from wherever.
Have fun!
i like my icon, made it myself...
except for Buttercap of course.
and for the symbol in the back that is copied from Slipknot...
I like the icon i use but isn't really mine.
-
Apr 3rd, 2004, 07:54 PM
#7
Fanatic Member
Thanks! I saw a few errors and try to fix them, but did not have much fortune. It works now though just as you have it. Thanks again!
If I add a label to capture the names of the textboxes though....aren't they actually named differently? My understanding is limited, but aren't control arrays supposed to be named the same thing?
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CreateMyTextBoxes()
End Sub
Const N = 4
Private mytextboxes() As TextBox
Private Sub CreateMyTextBoxes()
ReDim mytextboxes(N)
Dim i As Short
For i = 1 To N
mytextboxes(i) = New TextBox
With mytextboxes(i)
.Name = "TB" & i
.Tag = i
.Location = New Point(50 + i * 50, 20 + i * 20)
End With
Me.Controls.Add(mytextboxes(i)) 'Add to the form
AddHandler mytextboxes(i).TextChanged, AddressOf SomeSub 'Add the event to some sub
Next
Label1.Text = mytextboxes(1).Name.ToString & " " & mytextboxes(2).Name.ToString _
& " " & mytextboxes(3).Name.ToString & " " & mytextboxes(4).Name.ToString
End Sub
Private Sub SomeSub(ByVal sender As System.Object, ByVal e As System.EventArgs)
MessageBox.Show("Textbox " & sender.tag & " changed!")
End Sub
End Class
Last edited by birthjay; Apr 3rd, 2004 at 08:20 PM.
-
Apr 3rd, 2004, 08:41 PM
#8
Member
Don't exactly understand your question but just to clarify things:
This is not a control array. It's something else. I don't know what to call it.
The names of the controls does not matter!
you don't even have to name them!(in the loop)
because obviously you can't write in the code before you compile TB1.text="hello"
because the compiler doesn't know any "TB1"
you can reference them only by using mytextboxes(n)
Instead of the index that was sent in control arrays i use the sender.tag value in the events.
i hope this helps. :)
i like my icon, made it myself...
except for Buttercap of course.
and for the symbol in the back that is copied from Slipknot...
I like the icon i use but isn't really mine.
-
Apr 4th, 2004, 01:33 AM
#9
Fanatic Member
Thanks! I am a bit of a newby and I appreciate the explanation. I will give it some study.
-
Apr 4th, 2004, 10:02 AM
#10
Frenzied Member
Originally posted by SnappleBoy
I'll try!
Vb.net - no control arrays! Very sad... 
The solution: Something else!
instead of simply using design view to create control arrays you do the following:
VB Code:
Const N = 4
Private mytextboxes() As TextBox
Private Sub CreateMyTextBoxes()
ReDim mytextboxes(N)
Dim i As Short
For i = 1 To N
mytextboxes(i) = New TextBox
With mytextboxes(i)
.name = "TB" & i
.tag = i
.location = New Point(50 + i * 50, 20 + i * 20)
End With
Me.controls.add(mytextboxes(i)) 'Add to the form
AddHandler mytextboxes(i).TextChanged, AddressOf SomeSub 'Add the event to some sub
Next
End Sub
Private Sub SomeSub(ByVal sender As System.Object, ByVal e As System.EventArgs)
messagebox.show("Textbox " & sender.tag & " changed!")
End Sub
That's it!
EDIT:syntax glitches fixed
No worries control arrays are back in the next version of VB.NET
-
Apr 4th, 2004, 01:42 PM
#11
Member
but we don't need it!!!
i was kidding! don't bring control arrays back for the sake of me!
w/o control arrays the files are much smaller and besides it's more fancy doing things this way... you know, coding stuff is much more cooler than "visual design" err. where did that come from? i remember the days... when basic wasn't visual and programmers had self respect hehe just kidding...
Last edited by SnappleBoy; Apr 4th, 2004 at 01:56 PM.
i like my icon, made it myself...
except for Buttercap of course.
and for the symbol in the back that is copied from Slipknot...
I like the icon i use but isn't really mine.
-
Apr 5th, 2004, 02:20 AM
#12
Thread Starter
Fanatic Member
Well, here's another way. Not only for SnappleBoy
1. Pulldown as many text boxes u want on ur form.
2. Add TextBoxArray control on ur form.
3. In Region "Windows Form Designer generated code" u will find customised settings like AcceptsReturn, Autosize, Backcolor etc for each TextBoxes. There you add the following code.
VB Code:
Me.MyTextBoxArray.SetIndex(Me.MyTextBox1, i)
'where "i" is ur index number. could be any positive number
Your TextBox control array is ready.
Hope it helps someone
Regards
-
Apr 5th, 2004, 07:15 AM
#13
Member
design view is for chumps.
(Bender(Futurama) Paraphrased)
i like my icon, made it myself...
except for Buttercap of course.
and for the symbol in the back that is copied from Slipknot...
I like the icon i use but isn't really mine.
-
Jan 28th, 2005, 11:58 AM
#14
New Member
Re: Migrating from VB6 to VB.Net
Hello,
I have a fairly complex app that I plan to migrate to VB.NET. My main concern is the graphics part of the app.
The app is a design tool and has a picture box to display the graphics. Line and PolyBezier are the main graphics functions that are being used.
I remeber reading that VB.NET graphics work very differently from VB6.0 and hence was wondering if this could hinder the migration. Would it rather be better to start from a scratch in VB.NET than migrate?
Your comments would be highly appreciated.
Thanks in advance.
-
Feb 4th, 2005, 03:58 AM
#15
Thread Starter
Fanatic Member
Re: Migrating from VB6 to VB.Net
migrating from vb6 to vb.net thru the wizard was never appreciated by anyone. 1st of all the wizard was developed not by microsoft but by a third party company. there are so many flaws in it.
i would suggest, u better start with a new project in .net, right from scratch.
regards and all the best
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
|