the_carpenter 21 Junior Poster in Training

Is this what you were looking for:

Dim TheDateTimeRightNow As DateTime = Now

        Dim iMonth As Integer = DatePart(DateInterval.Month, TheDateTimeRightNow)
        Dim iDay As Integer = DatePart(DateInterval.Day, TheDateTimeRightNow)
        Dim iYear As Integer = DatePart(DateInterval.Year, TheDateTimeRightNow)
        Dim iHour As Integer = DatePart(DateInterval.Hour, TheDateTimeRightNow)
        Dim iMinute As Integer = DatePart(DateInterval.Minute, TheDateTimeRightNow)
        Dim iSecond As Integer = DatePart(DateInterval.Second, TheDateTimeRightNow)
the_carpenter 21 Junior Poster in Training

Well, if it's connected to a database what would you need to save? Is the data saved in the database?

the_carpenter 21 Junior Poster in Training

gridview?

Are you not connecting that to a data source anyway?

But if you did want to save every setting of a grid view... you would need to manually go through and save each settinng with a new line of savesetting.

the_carpenter 21 Junior Poster in Training

You could always save each field by using

SaveSetting(My.Application.Info.Title.ToString, "SearchForm", "Textbox1", textbox1.txt) 
' Do a version of the line above for each field you want to save

Then when you reload the form put the following in the load event

Textbox1.text = GetSetting(My.Application.Info.Title.ToString, "SearchForm", "Textbox1", "(default)")
the_carpenter 21 Junior Poster in Training

OK. On to the form which is unimaginatively called Form1 and I added a small picture picture box in the lower right hand corner with a picture that reads "START". Also, I added a timer control to the form called gameTimer. The biggest problem with graphics is the flickering so I draw all the shapes on to a bitmap and then draw the bitmap on to the form.

The timer is set to disabled at the beginning and its interval is set to 100.

So first off... the imports...

above Public Class Form1 place the following statement:

Imports System.Drawing.Drawing2D

Now the fields, place these statements just after Public Class Form1:

Private FallingObjects As New Collection
    Private gameTick As Int32
    Private gameLevel As Integer
    Private m_BufferBitmap As Bitmap
    Private m_BufferGraphics As Graphics
    Private m_Graphics As Graphics
    Private m_Xmax As Integer
    Private m_Ymax As Integer

Now the Form Load. I maximized the window, turn on Double Buffering, create some Graphics and a Bitmap. Also note, I create 20 new FObj:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' Save the screen width and height.
        Me.WindowState = FormWindowState.Maximized
        Me.DoubleBuffered = True

        m_Xmax = Me.Width
        m_Ymax = Me.Height

        ' Make a buffer Bitmap and Graphics.
        m_BufferBitmap = New Bitmap(m_Xmax, m_Ymax)
        m_BufferGraphics = Graphics.FromImage(m_BufferBitmap)

        ' Create a Graphics object for the form.
        m_Graphics = CreateGraphics()

        Dim i As Integer


        For i = 1 To 20
            Dim obj As New FallingObj()
            FallingObjects.Add(obj, i.ToString)
        Next
        'Me.DoubleBuffered …
the_carpenter 21 Junior Poster in Training

Basically im trying to make a game where shapes fall from the sky and the user controls the sprite to avoid them. I have it working but only with 1 block falling at a time. I am using the paint method to draw my shapes. I was wondering how to go about coding it so that it created multiple shapes, but they would be created at 1 second intervals so that there is a gap as the follow on from one another. This game is similar to "falldown" for the Iphone however the shapes come from the top. Any advice is appreciated.

Thanks

I'm no game designer and I've never played with an iPhone... but if you're interested in reading how a business programmer would attempt solving this problem... read on.

So, the falling shapes are objects... falling objects (lets call them fObj) need a class so that you can create multiple falling objects and you can set and retrieve the the FObj's properties and execute their methods. Something like:

Public Enum ShapeTypes
    FallingSquare = 1
    FallingCircle = 2
    FallingDiamond = 3
    FallingMoon = 4
End Enum

Public Class FallingObj

    Private _angularSpeed As Integer
    Private _shapeColor As Color
    Private _location As Point
    Private _speed As Integer
    Private _shape As ShapeTypes
    Private _rotation As Integer
    Private _size As Integer

    ''' <summary>
    ''' The position of the object
    ''' </summary>
    ''' <value>The new location of the object</value>
    ''' <returns>A Point of the new object</returns>
    ''' <remarks></remarks>
    Public Property Location() As …
the_carpenter 21 Junior Poster in Training

You database is not set up correctly. What it sounds like you want is to have a one to many relationship between sample and tbl_educ. But you can't without having a unique field in tbl_educ.

Change tbl_educ to include a new field that becomes it's primary index, so call the field tbl_educ_id, make it a long integer (or integer) make the field unique and auto increment (or an identity Column) and make it primary index.

Now make a relationship between emp_id between the two tables and now it will be a one to many setup.

The way you had it, it could only be a one to one relationship.

the_carpenter 21 Junior Poster in Training

not one line of code... but a subroutine to do all textboxes. And you can make it global so it can be called from Any Form.

Add a new code module to your project. Add the following code to the module:

Public Sub SetTextBoxAlignment(ByRef TargetForm As Form, ByVal tbAlignment As Windows.Forms.HorizontalAlignment, Optional ByRef WatchForExceptions As Boolean = False)

        For Each ctlOnForm As Control In TargetForm.Controls
            If TypeOf ctlOnForm Is TextBox Then
                Dim tmpTB As TextBox = DirectCast(ctlOnForm, TextBox)


                If String.IsNullOrEmpty(tmpTB.Tag) Then
                    tmpTB.TextAlign = tbAlignment

                Else
                    If WatchForExceptions Then
                        If Not tmpTB.Tag.ToString.StartsWith("x") Then
                            tmpTB.TextAlign = tbAlignment

                        End If
                    Else
                        tmpTB.TextAlign = tbAlignment
                    End If

                End If
            End If
        Next
    End Sub

How to use the above Subroutine:

This will set the textbox alignment for the current form to center:

SetTextBoxAlignment(Me, HorizontalAlignment.Center)

If you want to set the alignment for most of the textboxes but one or two, place an "x" in the Tag properties of those textboxes you which to exclude. Then use this line to set the alignment for all the textboxes except the ones you "Tagged".

SetTextBoxAlignment(Me, HorizontalAlignment.Center, True)
the_carpenter 21 Junior Poster in Training
Dim sTemp As String = ""
        TextBox1.Multiline = True
        TextBox1.Dock = DockStyle.Fill
        TextBox1.ScrollBars = ScrollBars.Vertical
        TextBox1.Font = New System.Drawing.Font("Courier New", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

        For i As Integer = 1 To 222
            sTemp = sTemp & String.Format("{0,6} {0, 10:X} {1, 10:C} {2, 10:C}", i, Convert.ToString(i, 8), Convert.ToString(i, 2)) & vbCrLf

        Next
        TextBox1.Text = sTemp
the_carpenter 21 Junior Poster in Training

Try setting the doublebuffered property of the form to true.

kvprajapati commented: Ofcourse +10
the_carpenter 21 Junior Poster in Training

the four text boxes (tA, tB, tC, tD)

one button (cmdCalculate)

and one more text box with a name that doesn't start with "t" (OutputTxtAvg)

Private Sub cmdCalculate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCalculate.Click

        Dim iNumeratorCnt As Integer = 0
        Dim iSum As Integer = 0

        For Each ctrl As Control In Me.Controls
            If ctrl.Name.StartsWith("t") Then
                Dim tmpText As New TextBox
                tmpText = DirectCast(ctrl, TextBox)
                If tmpText.Text.Length > 0 Then
                    Try
                        iSum += Val(tmpText.Text)
                        iNumeratorCnt += 1


                    Catch ex As Exception
                        MessageBox.Show("Please enter valid integers", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End Try
                End If

            End If
        Next
        If iNumeratorCnt > 0 Then
            OutputtxtAvg.Text = Convert.ToDouble(iSum / iNumeratorCnt)
        End If

    End Sub
the_carpenter 21 Junior Poster in Training

What kind of error do you get? What happens when you run the code?

the_carpenter 21 Junior Poster in Training

if you don't want to read a text file you can get the data in one of ... ummm.... two ways that I can think of.

1. Do it in-line like the suggestion that GeekbyChoiCe showed you.
2. Do it by importing from a resource, like resource strings.

You know... if I wasn't so stupid... I would say that you could attach a database... but I'm stupid... so we'll ignore that comment.

Back to resource strings. The bogus thing about adding the strings... they want a name to identify the string and then the string itself. Almost too good to be true... you the FunctionNumber as the name and the String is the description of the function (or whatever).

Oh... so I was saying that they're bogus. Because "44" is not a valid name for string resource. However, "A44" is valid. So I took the listing.txt and put it in the resource strings of the project to look much like this:
A1223 Your sister is cute
A1299 Can I get he phone number
A2345 While you are on your business trip
A422 Love me or Leave me Baby
A44 Time Time Time is on my side
A4444 Someone will need to check up on here
A5543 I can help her with her 12 step program
A7776 Sex addicts
A88 Pizza every morning
A8871 And their soriorty sisters
A9811 who need guidence

But at …

the_carpenter 21 Junior Poster in Training

What doing the conversion? Visual Studio?

Try Artinsoft Visual Basic Upgrade Companion.

They have a free 1 month/ 10,000 lines of code limit. But it could get you further along.

Simran Kaur commented: was helpful +1
the_carpenter 21 Junior Poster in Training

I know I'm doing this wrong... but in my current state of mind I can't think of exactly where I'm getting my information crossed.

Anyway... I played around with the IndexOf function in the clsFunctionXref

and this is what I got replace the IndexOf function with this one...

Public Function IndexOf(ByVal value As Object) As Integer Implements System.Collections.IList.IndexOf
        SyncLock Me.SyncRoot
            Dim tmpFnInfo As New clsFunctionInfo
            Dim tmpFunctionNumber As Integer
            Dim tmpidx As Integer = -1

            tmpFnInfo = DirectCast(value, clsFunctionInfo)
            tmpFunctionNumber = tmpFnInfo.IFunctionNumber

            For Each obj In _colFunctionInfo
                tmpFnInfo = DirectCast(obj, clsFunctionInfo)
                If tmpFunctionNumber = tmpFnInfo.IFunctionNumber Then
                    tmpidx = tmpFnInfo.IdxFunction
                    Exit For

                End If
            Next
            Return tmpidx
        End SyncLock

    End Function

So then I put a textbox and a button on the same form with the listbox

And then added this to the button_click

Dim iLookupNumber As Integer = 0

        Dim tmpFnInfo As New clsFunctionInfo
        Dim iReturnIdx As Integer = -1
        If TextBox1.Text.Length > 0 Then
            Try
                iLookupNumber = Convert.ToInt32(TextBox1.Text.ToString)

            Catch ex As Exception
                TextBox1.Text = ""
                MessageBox.Show("Enter a number, please.", "Come on... what are you doing here?", MessageBoxButtons.OK, MessageBoxIcon.Warning)

            End Try
            If iLookupNumber <> 0 Then
                tmpFnInfo.IFunctionNumber = iLookupNumber

                iReturnIdx = _objFnXtef.IndexOf(tmpFnInfo)
                If iReturnIdx <> -1 Then
                    ListBox1.SelectedIndex = iReturnIdx - 1
                End If


            End If
        End If

Completely insane, bassakwards and and screwed up but it works....

the_carpenter 21 Junior Poster in Training

mmm... ok...
without visual studio here... I can't debug the code...

Let me see if I have the visual studio disk here... and I will install it and figure this out...

I think it has something to do with the...

Default Public Property Item(ByVal index As Integer) As Object Implements System.Collections.IList.Item

being declared as an object and not as a clsFunctionInfo

I'll get back to you.

the_carpenter 21 Junior Poster in Training

I'm sure there is easier ways to do this same task... but the reason I would do it this way is so you can add in more complexity to the clsFunctionXref class.

Such as a SaveFile subroutine, or more logic to the iFunctionNumber such as verification of format or checks that it doesn't already exist, etc.

the_carpenter 21 Junior Poster in Training

easy...

You have the function number...

dim iStartUpFunctionNumber as integer = 422

combobox1.selectedindex =_objFnXtef.item(iStartUpFunctionNumber).IdxFunction

I think this should work. I didn't have VIsual Studio open to test it...

of course the above code will only work in the form because the object _objFnXtef is only declared in the form's context. (ooo... I just noticed a misspelling in the variable name but it doesn't matter)

the_carpenter 21 Junior Poster in Training

Since the listbox implements IList, make a class that implements IList and connected to the listbox's datasource.

For example:
Here is your basic class

Public Class clsFunctionInfo

    Private _idxFunction As Integer

    Public Property IdxFunction() As Integer
        Get
            Return _idxFunction
        End Get
        Set(ByVal value As Integer)
            _idxFunction = value
        End Set
    End Property
    Private _strFunction As String

    Public Property StrFunction() As String
        Get
            Return _strFunction
        End Get
        Set(ByVal value As String)
            _strFunction = value
        End Set
    End Property

    Private _iFunctionNumber As Integer
    Public Property IFunctionNumber() As Integer
        Get
            Return _iFunctionNumber
        End Get
        Set(ByVal value As Integer)
            _iFunctionNumber = value
        End Set
    End Property

End Class

Then you make a class to manage your collection of the above classes

Imports Microsoft.VisualBasic.FileIO

Public Class clsFunctionXref
    Implements System.Collections.IList

    Private _colFunctionInfo As New Collection

    Private _filePath As String
    Public Property FilePath() As String
        Get
            Return _filePath
        End Get
        Set(ByVal value As String)
            _filePath = value
        End Set
    End Property



    Public Sub New(ByVal filename As String)
        _filePath = filename

        Dim _idx As Integer = 1
        Dim fields As String()
        Dim delimiter As String = ","
        Dim iFnx As Integer
        Using parser As New TextFieldParser(filename)
            parser.SetDelimiters(delimiter)
            While Not parser.EndOfData
                ' Read in the fields for the current line
                fields = parser.ReadFields()

                Try
                    iFnx = Convert.ToInt16(fields(0).ToString)
                Catch ex As Exception
                    MessageBox.Show("Error reading file.  " & ex.ToString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    Exit Sub
                End Try

                Dim objFunction As New clsFunctionInfo
                objFunction.IdxFunction = _idx
                objFunction.IFunctionNumber = iFnx
                objFunction.StrFunction = fields(1).ToString
                Me.Add(objFunction)
                _idx += 1

            End While
        End …