Page 1 of 2 12 LastLast
Results 1 to 40 of 54

Thread: Add Procedure, does it exist in VB.Net?

  1. #1

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Add Procedure, does it exist in VB.Net?

    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",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Add Procedure, does it exist in VB.Net?

    Just type something like:
    VB Code:
    1. public property MyProperty as string
    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.

  3. #3
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Re: Add Procedure, does it exist in VB.Net?

    I don't think that exists in .Net, rather, type it along the class scope.

    public class SomeClass
    ' ... Some Generated Code

    sub SomeSubRoutine()
    end sub

    function SomeFunction() as SomeType
    return SomeTypeVarialbe
    end function

    end class

    I guess, that takes time but worth a doing.

    Edit: Opps. jmcilhinney replies faster.
    Last edited by nebulom; Jul 15th, 2005 at 12:34 AM.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    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.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?

    Wouldn't it a "good" idea to use the upgrade wizard just to discover the equivalent of those vb6.0 functions, methods, events, etc in .Net?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    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.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Add Procedure, does it exist in VB.Net?

    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.

  8. #8

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?

    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",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Add Procedure, does it exist in VB.Net?

    Quote Originally Posted by dee-u
    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.

  10. #10

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?

    So, am I correct to think not the upgrade wizard really just converts one's vb6.0 code to Microsoft.VisualBasic?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  11. #11
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Bath, England
    Posts
    411

    Re: Add Procedure, does it exist in VB.Net?

    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.

  12. #12

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?

    Wow, thanks a lot for that Parallax!
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    Nice link Parallax. I just going to have to read it all now.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?

    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",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    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.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?

    How about these Gangsta Yoda?

    Name 'Asc' is not declared
    Name 'IsNumeric' is not declared
    Name 'Chr' is not declared
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  17. #17
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    I havent see an exact equilivalent for Chr and Asc but this may help?
    VB Code:
    1. 'Get the first character in the string test
    2. Dim test as string = "Gangsta Yoda!"
    3. Messagebox.show(test.Chars(0).ToString()) '"G"
    Last edited by RobDog888; Jul 20th, 2005 at 01:15 AM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  18. #18

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?

    How about this?

    VB Code:
    1. Format$(Date, "mmddyyyy")

    This is actually where I need the Asc and Chr, could you help me out convert it to .Net? It capitalizes all alphabets in a textbox...

    VB Code:
    1. Private Sub txtData_KeyPress(Index As Integer, KeyAscii As Integer)
    2.     KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
    3. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  19. #19
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Add Procedure, does it exist in VB.Net?

    Quote Originally Posted by dee-u
    How about these Gangsta Yoda?

    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.

  20. #20
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Add Procedure, does it exist in VB.Net?

    Quote Originally Posted by dee-u
    How about this?

    VB Code:
    1. Format$(Date, "mmddyyyy")

    This is actually where I need the Asc and Chr, could you help me out convert it to .Net? It capitalizes all alphabets in a textbox...

    VB Code:
    1. Private Sub txtData_KeyPress(Index As Integer, KeyAscii As Integer)
    2.     KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
    3. End Sub
    myDate.ToString("MMddyyyy")

    Note that as Date in an inbuilt data type, I have changed the variable name to myDate.

    KeyAscii = Convert.ToInt32(Char.ToUpper(Convert.ToChar(KeyAscii)))

  21. #21
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Add Procedure, does it exist in VB.Net?

    I just re-read your previous post. Just set the CharacterCasing property of the TextBox to Upper and it's done for you.

  22. #22
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    But the CharacterCasing will convert the entire string. It needs Proper Casing. Is there one for that?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  23. #23

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?

    And how about this code of mine in VB6.0, could it be possibly converted to .Net?

    VB Code:
    1. Private Sub PopulateBL()
    2.         '<EhHeader>
    3.         On Error GoTo PopulateBL_Err
    4.         '</EhHeader>
    5.         Dim rsRecords As New ADODB.Recordset
    6. 100     With rsRecords
    7. 102         .Open "SELECT HBL_BLNumber FROM HBL WHERE HBL_Status <> 3", cnn, adOpenDynamic, adLockOptimistic
    8. 104         Do While Not .EOF
    9. 106             cboBL.AddItem .Fields("HBL_BLNumber")
    10. 108             .MoveNext
    11.             Loop
    12. 110         cboBL.AddItem vbNullString
    13. 112         .Close
    14.         End With
    15. 114     Set rsRecords = Nothing
    16.       '<EhFooter>
    17.       Exit Sub
    18.  
    19. PopulateBL_Err:
    20.         Select Case ErrorGlobalHandler("AISIS.frmHBL.PopulateBL")
    21.         Case vbAbort
    22.              Exit Sub
    23.         Case vbRetry
    24.              Resume
    25.         Case vbIgnore
    26.              Resume Next
    27.         Case Else
    28.              MsgBox Err.Description, vbCritical, "Critical Error Encountered"
    29.              End
    30.         End Select
    31.       '</EhFooter>
    32. End Sub
    33.  
    34.  
    35. Public Function ErrorGlobalHandler(ByVal strErrorSource As String) As Long
    36.     Dim strErrorMessage As String
    37.     strErrorMessage = "Error Occured In:  " & strErrorSource & vbCrLf & _
    38.                       "Error Date & Time: " & Now & vbCrLf & _
    39.                       "Error Description: " & Err.Description & vbCrLf & _
    40.                       "Error Number:      " & Err.Number & vbCrLf & _
    41.                       "Line Number:       " & Erl & vbCrLf
    42.     'Pass to other subroutine to trap any error that might occur in the ErrorGlobalHandler
    43.     ErrorGlobalHandler = PromptAndLogError(strErrorMessage, App.Path)
    44. End Function
    45.  
    46. Public Function PromptAndLogError(ByVal ErrorMessage As String, ByVal SystemPath As String, Optional ShowPrompt As Boolean = True) As Long
    47.     On Error Resume Next
    48.     Dim fso As New FileSystemObject, tsm As TextStream, ErrorFile As String
    49.     ErrorFile = SystemPath & "\ErrorLog" & Format$(Date, "mmddyyyy") & ".txt"
    50.     If fso.FileExists(ErrorFile) = True Then
    51.         Set tsm = fso.OpenTextFile(ErrorFile, ForAppending)
    52.         tsm.Write String$(30, "-") & vbCrLf & ErrorMessage
    53.         tsm.Close
    54.         Set tsm = Nothing
    55.         Set fso = Nothing
    56.     Else
    57.         Set tsm = fso.CreateTextFile(ErrorFile, True)
    58.         tsm.Write ErrorMessage
    59.         tsm.Close
    60.         Set tsm = Nothing
    61.         Set fso = Nothing
    62.     End If
    63.     If ShowPrompt = True Then
    64.         PromptAndLogError = MsgBox(ErrorMessage & vbCrLf & "Please report to the programmer any persistent error.   ", vbCritical + vbAbortRetryIgnore, "Error Encountered")
    65.     End If
    66. End Function
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  24. #24
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    Proper casing.
    VB Code:
    1. Dim test As String = "gangsta Yoda"
    2. test = test.ToUpper.Chars(0) & test.Substring(1)
    3. MessageBox.Show(test) '"Gangsta Yoda"
    Last edited by RobDog888; Jul 20th, 2005 at 01:16 AM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  25. #25
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    You should try to use ADO.NET instead of ADODB.

    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.
    Attached Images Attached Images  
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  26. #26

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?

    Its not the Ado that I'm concerned with, its the error handling scheme? Could it be converted to .Net? Anybody who could help me out converting it?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  27. #27
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Add Procedure, does it exist in VB.Net?

    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:
    1. Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
    2.         Dim newText As String = Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Me.TextBox1.Text)
    3.  
    4.         If Me.TextBox1.Text <> newText Then
    5.             Dim cursorPosition As Integer = Me.TextBox1.SelectionStart
    6.  
    7.             Me.TextBox1.Text = newText
    8.             Me.TextBox1.SelectionStart = cursorPosition
    9.         End If
    10.     End Sub

  28. #28
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    Ok, take the
    "On Error Resume Next"
    "On Error GoTo PopulateBL_Err"
    PopulateBL_Err:
    and replace the handling with a Try Catch block.

    VB Code:
    1. Try
    2.     'Do you stuff that has a potential for errors
    3. Catch ex As Exception
    4.     MessageBox.Show(ex.Source & " - " & ex.Message)
    5. End Try
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  29. #29

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?

    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",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  30. #30
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    Use ex.StackTrace to get the line number that threw the exception.

    You would also remove that too. You can wrap a global Try Catch block if your starting your app from a module or doing Application.Run(Form1).

    VB Code:
    1. Public Module1
    2.     Public oForm1 As New Form1
    3.     Public Sub Main()
    4.         try
    5.             Applicaation.Run(oForm1)
    6.         catch ex as exception
    7.             MessageBox.Show(ex.Source & " - " & ex.Message, ex.StackTrace)
    8.         end Try
    9.     End Sub
    10. End module
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  31. #31

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?



    How does that work? How about if I'll have Try... Catch in my procedures? Will it still go to that global Catch?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  32. #32
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    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.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  33. #33
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    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.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  34. #34

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?

    How about this?
    Quote Originally Posted by dee-u
    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",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  35. #35
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    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.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  36. #36

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?

    Thanks a lot Rob. But would you believe I got a neg. rep for this thread?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  37. #37
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    I found the srticle at MS. Its actually a good read to learn more on error handling in .NET

    http://msdn.microsoft.com/library/de...tml/vb01f1.asp

    Its compliments of kfcSmitty in my error thread here.

    Really? Maybe they made a mistake or dont understand whats going on in this thread?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  38. #38

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Add Procedure, does it exist in VB.Net?

    Double.TryParse and ControlChars raises some errors! Why is it? Did I miss something?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  39. #39
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Add Procedure, does it exist in VB.Net?

    Sorry DU, looks like the ControlChars is also in the MS.VB namespace. Since you removed the reference that is perhaps why
    your getting the error.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  40. #40
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Add Procedure, does it exist in VB.Net?

    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.

Page 1 of 2 12 LastLast

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