In VB6.0 there is the Add Procedure wherein one could easily make procedures like Sub, Function, Property or Event, what is its equivalent in VB.Net? I am actually starting to learn VB.Net, I used the Upgrade Wizard to upgrade an app I have made in VB6.0 which consists of only two forms but when it was converted it told me to add a property (IsInitializing or the like, forgot it) because my app from VB6.0 had a code in the Form_Resize event, there was a note/remarks added to the upgraded app that I need to add a property to determine if the app is still loading or something...
This is my first post in VB.Net and its the first time I visited this section.
Regards,
™
As a gesture of gratitude please consider rating helpful posts. c",)
and hit ENTER and all the default structure of the property definition will be entered for you by the IDE. As far as I'm aware there are no menu options or shortcuts to do this type of thing. Given that you would have to add arguments and return types yourself anyway, as well as change the name, I'd guess that just typing the definition yourself would be no slower and maybe faster. The IDE does do some things for you, though, like with properties as I've already mentioned. It also adds "End Sub", "End Function" and "ByVal" for you. Intellisense also makes declaring argument types and return types quicker.
VB6 upgrade wizard, ewe Good luck using it as your seeing. I would recommend you rewrite the app in .net instead (if time allows).
Usually when you rewrite an app you almost always write it better and more effecient.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
You could possibly do that but when you figure out things out on your own by looking in the help file your more likely to remember
and understand the reasons and definitions of the equilivalent funtions.
Kind of like the Forums. If you ask a question and someone writes the code for you and you copy/paste it into your app you really dont get
the benefit of learning.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
I'm not sure, given that I've never used the upgrade wizard, but I'd say VB6 functions will generally be upgraded to the equivalent VB Runtime function, so you would never get the System-based equivalent any way, e.g. MsgBox would be upgraded to MsgBox rather than MessageBox.Show. That's why I say use the Runtime functions for now but explore and be on the lookout for System-based alternatives.
How/where can I find their System-based alternatives? After some reading I think I will not use Microsoft.VisualBasic namespace so as to really code the .Net way, how/where can I disable it?
Regards,
™
As a gesture of gratitude please consider rating helpful posts. c",)
How/where can I find their System-based alternatives? After some reading I think I will not use Microsoft.VisualBasic namespace so as to really code the .Net way, how/where can I disable it?
If you really want to prevent yourself from inadvertently using a Runtime function then you should open the properties dialogue for the project and go to Common Properties -> Imports and remove the Microsoft.VisualBasic entry. As for finding the System-based alternatives, there isn't really a list anywhere that I'm aware of that shows Runtime functions and their System equivalent. I'd not be surprised if some zealot had compiled one somewhere, though. Otherwise, it's just observation, investigation and experience.
As for finding the System-based alternatives, there isn't really a list anywhere that I'm aware of that shows Runtime functions and their System equivalent.
MSDN has a very comprehensive list on this, take a look here.
When I removed the Microsoft.VisualBasic namespace the ff. error occurred and I couldn't figure out what to do...
Name 'Asc' is not declared
Name 'IsNumeric' is not declared
Name 'Chr' is not declared
Name 'vbCrLf' is not declared
Name 'Err' is not declared
Name 'Erl' is not declared
vbNullString also causes an error... Should I replace it with ""?
Regards,
™
As a gesture of gratitude please consider rating helpful posts. c",)
You need to replace those functions with VB.NET functions.
String.Empty = vbNullString
ControlChars.NewLine = vbCrLf = vbNewLine
ControlChars.CrLf = vbCrLf = vbNewLine
Err and Erl do not exist in .NET - Use a Try Catch block
Etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Name 'Asc' is not declared
Name 'IsNumeric' is not declared
Name 'Chr' is not declared
Use Convert.ToInt32 instead of Asc and Convert.ToChar instead of Chr. Although it's a tiny bit less staightforward, use Double.TryParse instead of IsNumeric.
You can show line numbers in the IDS automatically by clicking:
Tools > Options > Text Editor > All Languages > General > Display > check "Line Numbers".
It will also show you what line number your cursor is on in the status bar at the bottom of the IDE on the right side.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
But dee-u said ALL letters. If you want proper casing then there isn't a property of the TextBox that can do it, but the TextInfo class has a ToTitleCase method that you can use on the whole string, e.g.:
VB Code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim newText As String = Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Me.TextBox1.Text)
If Me.TextBox1.Text <> newText Then
Dim cursorPosition As Integer = Me.TextBox1.SelectionStart
How about the functions ErrorGlobalHandler and PromptAndLogError? Couldn't
I log the errors anymore and pinpoint what specific line the error occurred?
How does the new error handling in .Net works now? No more resume next and resume? How will it go back to the line where the error occurred or skip any line?
Regards,
™
As a gesture of gratitude please consider rating helpful posts. c",)
It works a similar way as it did in VB6. If you have nested error handling then it will buble up the path of Try Catches until it
gets to the last one.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Say you have a Try Catch in your Form1 from my example. Then Form1 generates an error thats inside form1's Try Catch block.
It will go to the forms Try Catch and display a messagebox (if you place one in there). Tne it will go to the Try Catch in the module and
display the messagebox message of the error and its source and stacktrace.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
How does the new error handling in .Net works now? No more resume next and resume? How will it go back to the line where the error occurred or skip any line?
In VB6.0 I really never used Nested Error handling.
Regards,
™
As a gesture of gratitude please consider rating helpful posts. c",)
There may be a way to have it resume but its not something I have tried yet. I was just reading about it today as a matter of fact.
When you catch the exception you can reset it (I think is how it was done) but if it errors again your out of luck.
I'll see if I can find the article on MS but I have not seen any examples from MS where they do this. Usually its just handle the error.
Last edited by RobDog888; Jul 15th, 2005 at 10:26 PM.
Reason: Type-O
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
ControlChars is indeed a member of a Microsoft.VisualBasic module. You can replace all the ControlChars constants, though. Use Environment.NewLine instead of ControlChars.NewLine, Convert.ToChar(Keys.Tab) instead of ControlChars.Tab, etc. Double.TryParse should give you no issues, though, as long as you give it the correct arguments.