Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Creating a Class in Visual Studios.Net (Visual Basic Section)

  1. #1
    dream is offline Newbie
    Join Date
    May 2008
    Posts
    18
    Rep Power
    0

    Creating a Class in Visual Studios.Net (Visual Basic Section)

    Hello, I am new to using Visual Studios.Net. I am trying to write a class using Visual Studios.Net in the Visual Basic section. Could someone tell me what I am doing wrong?

    Module Module1

    Public Class MyClassName

    End Class
    Sub New()
    Dim intVariable As Integer
    intVariable = 0

    End Sub
    Property Variable() As Integer
    Get
    Return Variable

    End Get
    Set(ByVal Value As Integer)
    Variable = Value
    End Set
    End Property
    MyClassName End Class
    REM I don't really know if End MyClassName should be at the end.
    REM book has End Class at the end.
    REM But the programs still manages to run I think.
    End Module

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

    The End Class should not be at the top, but at the bottom with the REM statements. Incidentally, you can now use the ' character instead of REM to comment.

    In VS using a module to write a class is a pointless way, when you can actually add your own class directly. To do this, go to Add New Item and choose Class. Give it a name, and accept. It should load up with code already set up. Simply add the methods to populate the class.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  4. #3
    dream is offline Newbie
    Join Date
    May 2008
    Posts
    18
    Rep Power
    0

    Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

    Thanks for the help.

  5. #4
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

    Is it working now?

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  6. #5
    dream is offline Newbie
    Join Date
    May 2008
    Posts
    18
    Rep Power
    0

    Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

    Yeah it is ok now. I am having problems activating my direct x controller though. I am reading a book called Gaming Programming for Teens. I believe that the author left out many important details about visual basic.

  7. #6
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

    Oh - maybe it's more of a book for advanced VB users. Is your computer powerful enough for Direct X?

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  8. #7
    dream is offline Newbie
    Join Date
    May 2008
    Posts
    18
    Rep Power
    0

    Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

    Yeah it should be. I just installed a graphics card geforce 7200 series. I past the test to see if it is obsolete. But since I am new to VB I don't really know who to initialize a device yet for direct X. Mainly I am just trying to write some code to form a window and changes its color to blue. I believe it has something to do with the adapters of the device or something of that nature.

  9. #8
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

    You shouldn't need DirectX just to display a form! Use a simple Form object, and change its BackColor to Color.Blue, like so:
    Code:
    Dim f As New Form()
    f.BackColor = Color.Blue
    f.Show()
    You can change any extra properties of the 'f' object before showing it, to make it look just the way you want it to.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  10. #9
    dream is offline Newbie
    Join Date
    May 2008
    Posts
    18
    Rep Power
    0

    Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

    Quote Originally Posted by Xav View Post
    You shouldn't need DirectX just to display a form! Use a simple Form object, and change its BackColor to Color.Blue, like so:
    Code:
    Dim f As New Form()
    f.BackColor = Color.Blue
    f.Show()
    You can change any extra properties of the 'f' object before showing it, to make it look just the way you want it to.
    It is that simple? Here is the command line that I am having problems with below:

    REM Create the Direct3D device
    device = New Direct3D.Device(adapterNumber, Direct3D.DeviceType.Hardware, Me, flags, params)


    Here is the program below:

    Imports Microsoft.DirectX

    Public Class Form1
    Inherits System.Windows.Forms.Form

    #Region " Windows Form Designer generated code "

    Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
    If Not (components Is Nothing) Then
    components.Dispose()
    End If
    End If
    MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    Private Sub InitializeComponent()
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 266)
    Me.Name = "Form1"
    Me.Text = "Form1"

    End Sub

    #End Region
    Dim device As Microsoft.DirectX.Direct3D.Device

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.Size = New Size(800, 600)
    Me.Text = "DirectX Initialization Demo"
    Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque, True)
    REM the above statements resize the window of the form

    REM set up the presentation parameters
    Dim params As New Direct3D.PresentParameters
    params.Windowed = True
    params.SwapEffect = Direct3D.SwapEffect.Discard
    params.AutoDepthStencilFormat = Direct3D.DepthFormat.D16
    params.EnableAutoDepthStencil = True
    params.BackBufferCount = 1
    params.BackBufferCount = 800
    params.BackBufferCount = 600

    REM Check video card capabilities
    Dim adapterNumber As Integer = Direct3D.Manager.Adapters.Default.Adapter
    Dim flags As Direct3D.CreateFlags
    flags = Direct3D.CreateFlags.HardwareVertexProcessing
    flags += Direct3D.CreateFlags.PureDevice

    Dim caps As Direct3D.Caps
    caps = Direct3D.Manager.GetDeviceCaps(adapterNumber, Direct3D.DeviceType.Hardware)
    If caps.DeviceCaps.SupportsHardwareTransformAndLight = False Or caps.DeviceCaps.SupportsPureDevice = False Then

    MessageBox.Show("Your video card is obsolete.", "Hardware Problem")
    End

    End If

    REM Create the Direct3D device
    device = New Direct3D.Device(adapterNumber, Direct3D.DeviceType.Hardware, Me, flags, params)

    End Sub

    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    device.Clear(Direct3D.ClearFlags.Target + Direct3D.ClearFlags.ZBuffer, Color.Blue, 1.0, 0)
    device.BeginScene()
    device.EndScene()
    device.Present()
    Me.Invalidate()
    End Sub
    End Class

    It is suppose to bring up a window and make the window blue.

  11. #10
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

    BLIMEY! Oh, I see. I have just remembered you are writing games. Just displaying a blue window is easy using the standard .NET functions, but once you start writing complex games, there will be a point where this long code will overtake the normal .NET ones in terms of usability.

    You see, the usual .NET framework is not designed to write games. This code might seem like a lot, but the more you try to draw to the screen, the easier it will seem.

    If you want to use the standard .NET commands, you can install the XNA Game Library. This provides an extra set of tools for writing games, but your DirectX thingy looks fine, and I advise you to stick with the code it gives you - my example could not in a million years write a game!

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Intermediate Visual Studio - C# Making Use of Visual Basic Namespace
    By chili5 in forum CSharp Tutorials
    Replies: 0
    Last Post: 08-26-2011, 01:53 PM
  2. Visual Basic Assighment Help. (Translating pseudocode to visual basic)
    By Adolf B in forum Visual Basic Programming
    Replies: 1
    Last Post: 03-18-2011, 09:16 PM
  3. Creating an image viewer in Visual Basic
    By blueparukia in forum Visual Basic Programming
    Replies: 5
    Last Post: 12-23-2010, 07:53 PM
  4. Few questions on Visual studio ultimate 2010 and visual basic
    By Steamsteam in forum Visual Basic Programming
    Replies: 0
    Last Post: 10-26-2010, 05:14 PM
  5. Visual Basic 2008 vs. Visual Basic 2005 - Compatibility
    By cande_300 in forum Visual Basic Programming
    Replies: 1
    Last Post: 01-23-2010, 09:00 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts