Browse DevX
Sign up for e-mail newsletters from DevX


VB.NET Faces Off Against Classic VB : Page 2

VB.NET, the .NET Framework, and Visual Studio.NET together form a potent combination that can simplify your code and reduce errors; however, to truly supplant existing versions of VB as a RAD tool, Visual Studio needs Break-Edit-Continue.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Create a GUID (Globally Unique ID)
GUIDs are an odd-looking series of numbers and characters, such as: {05589FA1-C356-11CE-BF01-00AA0055595A}. You might expect that GUIDs, because they're how COM distinguishes between objects, would be easy to create in classic VB, which depends on COM. And you might expect that they'd be harder to create in VB.NET, which doesn't depend on them. So much for expectations.

Classic VB:

   Private Declare Function CoCreateGuid Lib _
      "ole32.dll" (buffer As Byte) As Long
   Private Declare Function StringFromGUID2 Lib _
      "ole32.dll" (buffer As Byte, ByVal lpsz As Long, _
      ByVal cbMax As Long) As Long
   Private Function getGUID() As String
      Dim buffer(15) As Byte
      Dim s As String
      Dim ret As Long
      s = String$(128, 0)
      ret = CoCreateGuid(buffer(0))
      ret = StringFromGUID2(buffer(0), StrPtr(s), 128)
      getGUID = Left$(s, ret - 1)
   End Function


   Private Function getGUID() As String
      GetGUID = "{" & _
         System.Guid.NewGUID().ToString & "}"
   End Function

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date