the_carpenter 21 Junior Poster in Training
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

Good idea, thines01. Open CMD.exe and navigate to your debug or release folder and then type in the executables name.

the_carpenter 21 Junior Poster in Training

Also to slow things down you can use Thread.Sleep(100) to slow it down by a 1/10 of a second.

Imports System.Threading
Console.WriteLine("Sleep for 2 seconds.")
Thread.Sleep(2000)
the_carpenter 21 Junior Poster in Training
Console.Readline()
the_carpenter 21 Junior Poster in Training

Dear Programmers

I have an issue when I place a label box / other component in the MDI Parent form and then open any child form the label box/ other component displayed in child form (Show in SpanShot), could you please help me out to regret this problem, Thanks in Advance.

You shouldn't add a label to a MDI form unless you add it to a toolbar or panel first because of problems like this.

Best to add a panel to an MDI form and then add your label to the panel.

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

Hi...

I've been doing ASP.Net for years, but I am very new at PHP.

I need to redirect a user to a specific page based on the refereeing page. There's no way to calculate what the page should be so I figure I would have to use MySQL and look up the target page.

The Table would look something like

REFERRER TARGET
========= =======
www.xyz.com/page2.html mysite.org/directory/lostparts.php
www.abc.net/goofy.aspx mysite.org/listings/trucks.html?ID=32

Does anybody know how I would get this accomplished?

Thank you

the_carpenter 21 Junior Poster in Training

Did that answer your question?

the_carpenter 21 Junior Poster in Training

I'm going to assume you have two PC's, one with an IP address similar to 10.1.1.21 and the other 10.1.1.25.

In this case both PC's are on the same network.

I'm thinking that ICMP (Internet Control Message Protocol) traffic is being blocked either from the installed firewalls on your PC's. ICMP is how ping and trace-route (tracert in windows) communicate. If it's not your PC's firewall blocking the ICMP it's your LAN switch blocking them.

If you are truly on two different networks where your IP's are in different subnets, for example PC1 is in 10.1.1.21 and the PC2 is 10.1.2.25 and your subnet mask is 255.255.255.0 then it could be the router blocking the ICMP.

So the question comes down to why block ICMP? Because DoS (Denial of Service)attacks originally came from a multitude of machines pinging a target in order to overwelm and over burden the target and its network so no one else could use it.

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

It is not very clear on what you are asking. PageID? PageID of what? Permissions to what kind of pages? Are we talking ASP.net, here?

the_carpenter 21 Junior Poster in Training

You are creating the SqlParameter Object but you're not adding it to the Command Object.

Sorry I don't have the time to look it up... but there should be some sort of method of the objCommand to add parameters to it.

something like
objCommand.Parameter.Add("@Name", SqlDbType.Int, 4)
objCommand.Parameters["@Name"].Value = ID.ToString

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

Please tell me you're not using in-line coded connection strings.

1: Hopefully you're using a connection string that isn't hard coded and/or in-line with your code.

A. If it is, you need someway to manage and alter that connection string via your application (have an options form or administration form)

B. If it isn't and you've made it part of settings you should have a .config file that has the same name as your exe. For example, if your application file name is WonderApp.exe then there should be a file called WonderApp.exe.config. You can carefully edit this file with notepad and change the connection string.

2. Hopefully you've been testing your application on a different computer from your development machine. You need to have a computer that doesn't have all the applications and development tools that your computer has installed. This second computer should be your QC (Quality Control) machine and it should be kept as clean as possible. (No extra applications... don't use it for a gaming machine)

When you install your app on the QC machine, you will see what you're missing from your setup package and how well your app really works in the real world. Without this machine you're just guessing your application will work. Without QC you will look bad every time one of your users discovers an error in your app.

kvprajapati commented: Good explanation!!! +10
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

Without the error message or output, this is just a guess.

Are any of the fields in Table1 not string. You might have to convert the Textbox.Text to a double, real, or possibly date.

the_carpenter 21 Junior Poster in Training

Hey Carpenter.

I'm running into a odd error with this code. If I post the error would you mind taking a look to see what it is? On some PC's it works fine, on some it doesn't.

Sorry was on a business trip... but I'm back now!!!! YEA! (Sometimes I can be a real dork.)

Anyway... post away... I'm always up for some debug and sleuth work.

the_carpenter 21 Junior Poster in Training

I don't know if using Mutex is wrong or not... I've never had to use it.

I've written several multi-threaded applications and when it comes to avoiding crossthreading in Shared Classes this is the only way I've done it.

So lets say I have a class ( clsDoSomeWork ) that will be our threads. And clsDoSomeWork as a method ( DoItNow( Name, Time) that we call to start each thread.

Public Class clsDoSomeWork

'This is our lock object
Private Shared objWorkLock as New Object

'This is our starting point for each thread
Public Sub DoItNow(ByVal strName as String, ByVal dtTime as DateTime)


'Here we would have some code that isn't going to access methods on other threads.
'For Example
For i as Integer = 1 to 5
   strName = String.Concat(strName, i.ToString)
Next 

'Now we have code that accesses a public variable or method on another thread.
'So we lock it down.
SyncLock objWorkLock

'Do some stuff like save data or write to the registry, etc.

End SyncLock

End Class
the_carpenter 21 Junior Poster in Training

Quick answer ( I can give more detail tonight if needed ):

Look into SyncLock

the_carpenter 21 Junior Poster in Training

You'll have to import it row by row then

the_carpenter 21 Junior Poster in Training

I just thought of something.

Save your data on the Excel spreadsheet as string.

When you enter a number in Excel precede it with an apostrophe ( ' )

This tells Excel to treat the data in this cell as a string value and not a number.

the_carpenter 21 Junior Poster in Training

While not a great expert at importing excel data, I tried your code and it does the same thing to me as well.

I'm pretty sure it something to do with the Bulk import function and it applying datatypes to each column based on what's in the first row. Is there some other method to import data other than SQLBulkCopy?

the_carpenter 21 Junior Poster in Training

Are you just trying to capture the output of an command line interface?

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

Did that solve your problem? Please mark this thread solved.

the_carpenter 21 Junior Poster in Training

So you're trying to do conditional formatting of the cell based on it's value? What version of Visual Studio are you using?

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 this solved your problem, please mark the thread as solved.

Thanks.

the_carpenter 21 Junior Poster in Training

These text files are they static or dynamic?

If they're dynamic, I'll assume another application is supplying them and then there is little you can do. You might be able to create an ACL and limit the number of people who can use and or look at the application and the data.

If they're static, you can do a couple of things to make more difficult to look at but if someone is determined there are ways around almost anything you do.

One thing you can do, instead of text files, you can incorporate the files into your application as resources. You would have to recompile the application every time you changed one of the text resources which could be a pain depending on distribution of you application and how many people receive it.

Another idea would be to encrypt the files and allow the application to decrypt them in memory to read them. But this would require you to encrypt text files prior to distribution; moreover, there would be no quick editing of the text files in place with notepad.

Or lastly, convert the files over to a secure database. Depending on the database you choose it could become an administration headache depending on distribution or would you self host a public database. This would be the most secure method.

the_carpenter 21 Junior Poster in Training

You changed something with the database.

What's the table called? PerInfo or Personnel ???

Be consistent. If the table is called Personnel... you need to change all those references from "PerInfo" to "Personnel"

the_carpenter 21 Junior Poster in Training

Did this happen after pressing add then update? What exactly did you do to create this error?

the_carpenter 21 Junior Poster in Training

Also, give your system time to process what you've asked it to do before sending the keystrokes by inserting the following prior to the send keys:

System.Threading.Thread.Sleep(500)
the_carpenter 21 Junior Poster in Training

Without knowing the following, it is impossible to tell you what's going on:

1. The values and types of your variables: nomAudio, nomImage, nomExamen and repTest
2. What exactly is line 119

What also might help is knowing the structure of your database. At the tables AUDIO, [IMAGE], and [TEST] and their dependencies.

the_carpenter 21 Junior Poster in Training

The axmscomm control I think has been replaced by the

System.IO.Ports.SerialPort control

At least that's what I could find in VS 2008

the_carpenter 21 Junior Poster in Training

Dude, I'd like a new car that doesn't brake down all the time.

Are you looking for help with coding it or are you just looking for a sample project?

There's all kinds of sample code on this site and on the Internet.

Such as http://www.codeplex.com

may also some ideas on how to improve the application.

How would we know how to improve your application if you haven't written it yet?

Try writing some code and if you have problems come and ask more specific questions.

the_carpenter 21 Junior Poster in Training

Ok... well as long as it's value isn't -1 and you're are pressing the save button after adding the new record and not the update button.

Side note: You really shouldn't enable the update button in the btnAddNew_Click I wouldn't think anyway.

So have you run through this stepping through the code to see where it's going wrong?

the_carpenter 21 Junior Poster in Training

Ok... if you say so...

I've never done data validation in this manner.

I took a sample data application that uses a version of the NorthWind Sample database and placed the following code in OrdersBindingSource_PositionChanged event.

MessageBox.Show(OrdersBindingSource.Current Is Nothing)

And it returned False every time I changed from order to order, or added an order. It never returned True (Meaning the the Current was something)

So if that's the case... I have to wonder why you are updating (or saving) a record for Products with the Product_DetailsBindingSource?

Shouldn't there be a ProductsBindingSource?

the_carpenter 21 Junior Poster in Training

So now it doesn't error but doesn't save the data?

What is the purpose of this line?:

If inc <> -1 Then

I don't see where it's declared or any value is being assigned to it.

the_carpenter 21 Junior Poster in Training

maybe repost your code... I think you missed something...

or maybe I did... :-)

the_carpenter 21 Junior Poster in Training

Not really... I would go with the most recent. Microsoft doesn't like to much to have to support older versions of their software. So if you ever have an incident with them, you don't want them to solve it by saying "Upgrade"

the_carpenter 21 Junior Poster in Training

Ok... no problem.

While I was at the station for their non-emergency... I worked on the a new sub for reading the resource string.

Add this to the clsFunctionXref class

Public Sub New()
        Dim thisExe As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
        Dim resources() As String = thisExe.GetManifestResourceNames()
        Dim fn As Integer
        Dim fname As String
        Dim _idx As Integer = 1
        For Each resource As String In resources
            thisExe.GetManifestResourceInfo(resource)
            Dim reader As New Resources.ResourceReader(thisExe.GetManifestResourceStream(resource))
            For Each entry As DictionaryEntry In reader
                fn = 0
                fname = ""

                fn = Convert.ToInt32(entry.Key.ToString().Remove(0, 1))
                fname = entry.Value().ToString()
                Dim objFunction As New clsFunctionInfo
                objFunction.IdxFunction = _idx
                objFunction.IFunctionNumber = fn
                objFunction.StrFunction = fname
                Me.Add(objFunction)
                _idx += 1


            Next
        Next
    End Sub

And then in the form change the line from this

Dim _objFnXtef As New clsFunctionXref(My.Application.Info.DirectoryPath & "\listing.txt")

To this:

Dim _objFnXtef As New clsFunctionXref()
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

Your database is expecting a number not a string.

If you can look at the design of your table, you will notice that that ContactNo is a number data format where all the other fields should be a Text data format.

And what you are doing is trying to push text into a data field only set up to take numbers. Even if the only thing in the textbox is numbers without an explicit conversion to a numeric (double) format the program will complain every time.

So... it's an easy fix.

ds.Tables("Personnel").Rows(inc).Item(6) = Convert.ToDouble(txtContactNo.Text)

You may have to add that conversion to the save as well as the update.

Other fields may complain too.

Possibly the date fields... not too sure.
But if they do use the Convert.ToDateTime(control.text)

the_carpenter 21 Junior Poster in Training

So there are a couple of ways to validate the format of an email address.

You could always to the simple look for the @ sign and make sure there is a dot (.) somewhere after the @ sign.

Or the kind of cool and groovy method of using Regular Expressions (RegEx).

Here's how you do it:
Add a textbox (Textbox1) and a button (Button1) to a form.

Switch to code view.

Add the imports statement

Imports System.Text.RegularExpressions

Then in your Button1_Click Event add the following code:

Dim strMessage As String = ""
        Dim regex As Regex = New Regex("([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\." + _
                                       ")|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})", _
                                       RegexOptions.IgnoreCase _
                                       Or RegexOptions.CultureInvariant _
                                       Or RegexOptions.IgnorePatternWhitespace _
                                       Or RegexOptions.Compiled _
                                       )
        Dim IsMatch As Boolean = regex.IsMatch(TextBox1.Text)
        If IsMatch Then
            If TextBox1.Text.Equals(regex.Match(TextBox1.Text).ToString) Then
                strMessage = "Valid email address"
            Else
                strMessage = "There's an email address in there somewhere.  But not exactly"
            End If
        Else
            strMessage = "Sorry.  Invalid email address format."
        End If
        MessageBox.Show(strMessage)

By the way there is no good way to tell if an address actually exists (or is valid) until you get a response back from the server telling you it doesn't exists. Unless of course you're the system administrator of that particular email server.