Friday, June 17, 2022

VB projects

VB projects

  1. Basics of a Falling Blocks Game in VB.NET 2005
  2. A remake of the classic falling blocks game in a modern language

  3. Advanced Shape Control
  4. Advanced Shape Control

  5. How to read embedded resource text file
  6. How do I read an embedded resource (text file) using StreamReader and return it as a string? My current script uses a Windows form and textbox that allows the user to find and replace text in a text file that is not embedded.

    VB Type conversion

  7. Type Conversion Functions (Visual Basic)
  8. These functions are compiled inline, meaning the conversion code is part of the code that evaluates the expression. Sometimes there is no call to a procedure to accomplish the conversion, which improves performance. Each function coerces an expression to a specific data type.

  9. DirectCast Operator (Visual Basic)
  10. Introduces a type conversion operation based on inheritance or implementation.

  11. How to cast from Object to Integer in VB.NET?
  12. How should I cast from an Object to an Integer in VB.NET?

  13. Type Casting in Visual Basic .NET
  14. Visual Basic .NET provides two options for casting.
    1. CType: Casts or converts one type into another type. If the types do not match, coercion may be performed.
    2. DirectCast: Casts one type to another type with better performance than CType, but does not perform coercion if the types do not match.

    Note: CType includes all of the VB conversion functions. These are CBool, CByte, CChar, CDate, CDec, CDbl, CInt, CLng, CObj, CShort, CSng, and CStr.

    The main difference between the two is that DirectCast only works if the specified type and the run-time type of the expression are the same. This difference only appears when converting from an object type to a value type, or unboxing a value.

  15. DirectCast - VB.Net
  16. DirectCast - VB.Net

    If this conversion is not possible then an exception is thrown. This is another way to convert between different datatypes. The DirectCast works in a similar way to the CType operator but has a few imporatant differences:

    1. It only works with arguments that are reference type. If you pass a Value type then a compilation error will occur.
    2. It cannot perform widening conversions from Short to Integer.
    3. It cannot perform widening conversions from Single to Double.
    This method is slightly faster that CType so you should use CType when you need to cast rather than convert a value.
  17. CType - VB.Net
  18. If this conversion is not possible then an exception is thrown. When you use Option Strict On any datatype conversions must be explicit.

  19. Explicit Conversion
  20. There are three ways of performing an explicit conversion in C#
    1. Brackets - returns an instance of the type you are requesting or an exception. Also known as prefix casting or type cast operator.
    2. As - returns an instance of the type you are requesting or null.
    3. System.Convert - returns an instance of the type you are requesting or an exception.
    There are three ways of performing an explicit conversion in VB.NET 0) DirectCast 1) CType 2) TryCast - the equivalent of As
  21. Casting Reference Types in Visual Basic .NET
  22. Casting, or converting the value of a token from one type of data to another is common to most (if not all) programming languages. Visual Basic has long had a series of casting functions, such as CStr, CInt, Clong, etc. to allow conversion of one type of variable to another. While the idea of casting is simple and familiar when discussed in the context of a simple variable containing a value (.NET value types), the meaning and behavior of a cast is less clear when discussed in the context of objects.

  23. Converting Variable Types
  24. In many situations, you will need to convert variables from one type into another. Table 2.4 shows the methods of the Convert class that perform data-type conversions.

    In addition to the methods of the Convert class, you can still use the data-conversion functions of VB (CInt() to convert a numeric value to an Integer, CDbl() to convert a numeric value to a Double, CSng() to convert a numeric value to a Single, and so on), which you can look up in the documentation. If you’re writing new applications in VB 2008, use the new Convert class to convert between data types.

  25. DirectCast vs. CType
  26. Ok, I understand that in .NET I can use either the CType or DirectCast to convert variable datatypes, from object type to a specific datatype (like SelectedValue in the combo to integer or string even).

    What I want to know is the advantages and disadvantages between the two. Is one preferred over the other? What are most people using? Is there a performance gain of any kind for either one? Or a perfomance disadvantage?

  27. VB.NET and C# Comparison
  28. This is a quick reference guide to highlight some key syntactical differences between VB.NET and C#. Hope you find this useful! Thank you to Tom Shelton, Fergus Cooney, Steven Swafford, Gjuro Kladaric, and others for your contributions. Also see Java and C# Comparison.

  29. Casting and Data Type Conversions in VB.NET
  30. Casting is the process of converting one data type to another. For example, casting an Integer type to a String type. Some operations in VB.NET require specific data types to work. Casting creates the type you need. The first article in this two-part series, Casting and Data Type Conversions in VB.NET, introduces casting. This article describes the three operators you can use to cast in VB.NET - DirectCast, CType and TryCast - and compares their performance.

  31. Type Conversion Functions
  32. If you code "mixed mode" assignment statements (i.e., assign a string to an integer, assign a single to a string, etc.), VB.NET will perform the necessary conversions in such statements whenever it possibly can (provided that "Option Strict" is off). Such conversions are called implicit conversions.

    However, you can also use a set of functions that explicitly convert (or "cast") one type of data to another. The set of functions that enable you to do this all begin with the letter "C": CBool, CByte, CDate, CDbl, CDec, CInt, CLng, CSng, CStr, etc. Alternatively, you can use a corresponding method from the VB.NET Convert class to accomplish the same result.

    In addition, two older functions, Val and Str, enable you to convert from a string to a number and from a number to a string, respectively.

    The "Cxxx" functions and their equivalent Convert class methods are shown in the table below:

  33. Difference Between DirectCast and TryCast
  34. What is the difference between DirectCast and TryCast

  35. DirectCast vs. CType vs. TryCast
  36. DirectCast, CType, or TryCast ?

    I would like to see a discussion on the differences, advantages, and different situations in which each of these are best used within the context of .NET programming for Autocad.

  37. Cast Integer to Enum value : Enum « Data Type « VB.Net Tutorial
  38. Cast Integer to Enum value : Enum « Data Type « VB.Net Tutorial

  39. Speed Up Your VB.NET Code
  40. Optimization rules have changed under VB.NET-here are eight great new ways to build wicked-fast code.

    Best Comparison

  41. VB.NET and C# Equivalents
  42. Equivalents were produced with Instant C# and Instant VB.

  43. How to: Convert an Object to Another Type in Visual Basic
  44. You convert an Object variable to another data type by using a conversion keyword such as CType Function.

  45. Best practice for converting an object to string
  46. I've seen a number of ways of converting an Object to a String in .NET, typically for displaying the object's value to the user when the object type is not known.

  47. Convert String to DateTime
  48. In .Net, you can work with date and time easy with the DateTime class. You can use the methods like Convert.ToDateTime(String), DateTime.Parse() and DateTime.ParseExact() methods for converting a string-based date to a System.DateTime object.

    My Lesson in converting VB to VC project

  49. Advanced Shape Control
  50. Advanced Shape Control

    Convert two projects one by one into C#. then load control project and compile it. then load client project and compile it. We will run into all kinds of errors.

    Control project type conversion is easy, but there are some quirks...

    Client project somehow has not static main(). then I neeed to add Program.cs file and update project property and reset entry method. set startup object as Program.

  51. CSC : fatal error CS2017: Cannot specify /main if building a module or library
  52. I got the same error while upgrading from .Net Framework 4.0 to 4.51. Removing the StartupObject from the csproj file fixed the problem.

    solution: I also had this problem however the startUpObject was already showing (not set) in the properties page. To fix this I reselected the (not set) StartUpObject which then cleared this value from the project file. The element is then reset in the csproj file:

    < StartupObject > </StartupObject >

    If that doesn't work then I guess you might aswell just edit the csproj file directly to remove any erroneous text in this element

  53. Does not contain a static 'main' method suitable for an entry point
  54. Step 1: If you don't have a file named Program.cs, just add a new Class and name it Program.cs. Then paste this code:

    namespace Sales { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } }

    Step 2: After placing the above code in Program.cs, follow below steps

    1. Right click on the project
    2. Select Properties
    3. Set Output Type to Windows Application
    4. Startup object : namepace.Program

  55. Compiler Error CS5001
  56. Program does not contain a static 'Main' method suitable for an entry point

    This error occurs when no static Main method with a correct signature is found in the code that produces an executable file. It also occurs if the entry point function, Main, is defined with the wrong case, such as lower-case main. For information about the rules that apply to the Main method, see Main() and Command-Line Arguments.

No comments:

Post a Comment