Oxiegen 88 Basically an Occasional Poster Featured Poster

No problem. :)
If you find my help useful, then please mark this thread as solved.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Yeah. Only one, though you may have tried it already.
You can treat the excel file as a database, and use OleDb and OleDbDataAdapter to push the data into it.

Oxiegen 88 Basically an Occasional Poster Featured Poster
Private Sub MethodThatCreatesDynamicPictureBoxes()
   'Your code for dynamically creating picturebox
   AddHandler yourPicBox.Click, AddressOf picbox_Click
End Sub

Private Sub picbox_Click(ByVal sender As Object, ByVal e As System.EventArgs)
   'Every time a picturebox is clicked, this variable will contain THAT picturebox
   Dim picBox As PictureBox = DirectCast(sender, PictureBox)

   'Do something with the picBox control
End Sub
Oxiegen 88 Basically an Occasional Poster Featured Poster

Well, belle.
What would you like to know more precisely?
There are a lot of things you can do with the ListView control.

The ListView control is simply to, well, list things from top to bottom.
If you put a ListView control on a form, you can do this in the Form_Load event:

ListView1.Items.Add("item1")
ListView1.Items.Add("item2")
ListView1.Items.Add("item3")
Oxiegen 88 Basically an Occasional Poster Featured Poster

You should have a look into the third-party component GemBox.SpreadSheet.
I'm using it myself, and it's very very fast.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Well. I figured that since you mentioned that the target would be a trashcan, then there would be no point in assigning an image to the target picturebox. That's why changed that line.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Ok. Then we need to change some things for the source picturebox.

Private bMouseIsDown As Boolean = False
Private Sub sourcePictureBox_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles sourcePictureBox.MouseDown
   If sourcePictureBox.Image IsNot Nothing Then
      bMouseIsDown = True
   End If
End Sub

Private Sub sourcePictureBox_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles sourcePictureBox.MouseMove
   If bMouseIsDown Then
      Dim pic As PictureBox = DirectCast(sender, PictureBox)
      Dim img As BitMap = pic.Image
      pic.Image = Nothing
      pic.DoDragDrop(img, DragDropEffects.Move)
      ' Or if you prefer to just copy the picture
      'pic.DoDragDrop(img, DragDropEffects.Copy)
   End If
   bMouseIsDown = False
End Sub

And for the target.

Private Sub targetPictureBox_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles targetPictureBox.DragDrop
   If e.Data.GetDataPresent(DataFormat.BitMap) Then
      Dim img As BitMap = e.Data.GetData(DataFormats.BitMap)
      If img <> sourcePictureBox.Image Then 'I don't know if this one will work
         sourcePictureBox.Image = img 'Restore the picture from the source
      End If
   End If
End Sub

And for the visibility while dragging. I found a discussion on another site that will give you the answer to that one. It will give a complete method for drag and drop of image.
http://www.tek-tips.com/viewthread.cfm?qid=1241165&page=1

Oxiegen 88 Basically an Occasional Poster Featured Poster

You're very welcome. :)
Please remember to mark this thread as solved.

Oxiegen 88 Basically an Occasional Poster Featured Poster

First.
In the form load event, add this line: targetPictureBox.AllowDrop = True

For the source picturebox, add this method:

Private Sub sourcePictureBox_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles sourcePictureBox.MouseDown
   Dim pic As PictureBox = DirectCast(sender, PictureBox)
   pic.DoDragDrop(pic.Image, DragDropEffects.Move)
   ' Or if you prefer to just copy the picture
   'pic.DoDragDrop(pic.Image, DragDropEffects.Copy)
End Sub

For the target picturebox, add these two methods:

Private Sub targetPictureBox_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles targetPictureBox.DragEnter
   If e.Data.GetDataPresent(DataFormats.Bitmap)
      e.Effect = DragDropEffects.All
   End If
End Sub

Private Sub targetPictureBox_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles targetPictureBox.DragDrop
   If e.Data.GetDataPresent(DataFormat.BitMap) Then
      Dim img As BitMap = e.Data.GetData(DataFormats.BitMap)
      'Insert comparison code here
      targetPictureBox.Image = img
   End If
End Sub
Oxiegen 88 Basically an Occasional Poster Featured Poster

Good luck!

Oxiegen 88 Basically an Occasional Poster Featured Poster

Ok.
I figured it out.
Replace all instances of SendKey "{DOWN}" with this line: ActiveCell.Offset(1, 0).Select

Oxiegen 88 Basically an Occasional Poster Featured Poster

Yeah. I can see that.

Do this instead.

Label43.Text = DateTime.Now.ToString("HH:mm:ss")
Dim time1 As DateTime = DateTime.Parse("1970-01-01 23:50:00")
Dim time2 As DateTime = DateTime.Parse("1970-01-01 23:51:00")

Dim compare As DateTime = DateTime.Parse("1970-01-01 " & Label43.Text)
If compare > time1 AndAlso compare < time1 Then
Oxiegen 88 Basically an Occasional Poster Featured Poster

Glad to hear it. :)
If this was helpful, please mark this thread as solved.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Ok.
I tried this out myself.
Replace the SendKeys line with: Application.SendKeys "{DOWN}", True

Oxiegen 88 Basically an Occasional Poster Featured Poster

Have you tried debugging?
Do you get any error messages?

Oxiegen 88 Basically an Occasional Poster Featured Poster

Ok. I didn't quite think that through. :)
Try this instead:

Imports System.Data.SqlClient
Imports System.Data
Imports MySql.Data.MySqlClient

Public Class MainForm
    Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MainForm.Load
        Timer1.Stop()

        ReadValues()
        Label42.Text = Label1.Text
        Label41.Text = Label2.Text
        Label30.Text = Label3.Text
        Label29.Text = Label4.Text
        Label28.Text = Label5.Text
        Label27.Text = Label6.Text
        ' And so on

        Timer1.Start()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ReadValues()
        StoreValues()
    End Sub

    Private Sub ReadValues()
        Label1.Text = EthernetIPforSLCMicro1.ReadAny("F16:0")
        Label2.Text = EthernetIPforSLCMicro1.ReadAny("F16:2")
        Label13.Text = EthernetIPforSLCMicro1.ReadAny("F15:0")
        Label14.Text = EthernetIPforSLCMicro1.ReadAny("F15:1")
        Label15.Text = EthernetIPforSLCMicro1.ReadAny("F15:2")
        Label16.Text = EthernetIPforSLCMicro1.ReadAny("F15:3")
        Label17.Text = EthernetIPforSLCMicro1.ReadAny("B13/16")
        Label18.Text = EthernetIPforSLCMicro1.ReadAny("B13/17")
        Label19.Text = EthernetIPforSLCMicro1.ReadAny("B13/18")
        Label20.Text = EthernetIPforSLCMicro1.ReadAny("B13/19")
    End Sub

    Private Sub StoreValues()
        Try
            Dim SQLStr As String

            'SQL Staments
            If PercentIncrease(Label1.Text, Label42.Text, Label42.Text) Then
                'SQL query = myQuery = "SQL Statment"
                SQLStr = "INSERT into xxxxx(id, f16_0, t_stamp) VALUES(' ','" & Label1.Text & "','" & Now() & "')"
                UpdateDatabase(SQLStr)
                Label42.Text = Label1.Text
            End If
            If PercentIncrease(Label2.Text, Label41.Text, Label41.Text) Then
                'SQL query = myQuery = "SQL Statment"
                SQLStr = "INSERT into xxxxx(id, f16_2, t_stamp) VALUES(' ','" & Label2.Text & "','" & Now() & "')"
                UpdateDatabase(SQLStr)
                Label41.Text = Label2.Text
            End If
            If PercentIncrease(Label13.Text, Label30.Text, Label30.Text) Then
                'SQL query = myQuery = "SQL Statment"
                SQLStr = "INSERT into xxxxx(id, f16_2, t_stamp) VALUES(' ','" & Label13.Text & "','" & Now() & "')"
                UpdateDatabase(SQLStr)
                Label30.Text = Label3.Text
            End If
            If PercentIncrease(Label14.Text, Label29.Text, Label29.Text) Then
                'SQL query = myQuery = "SQL Statment"
                SQLStr = "INSERT into xxxxx(id, f16_2, t_stamp) VALUES(' ','" & Label14.Text …
Oxiegen 88 Basically an Occasional Poster Featured Poster

You need to embrace the word DOWN in braces: SendKeys("{DOWN}").
SendKeys Reference

Oxiegen 88 Basically an Occasional Poster Featured Poster

Oh.

You can do this.
When you first start the program, immediatly fetch the value from the device and store it in both label1 and Label42.
Then during the timer tick event, perform the comparison, and if the result is as wanted, update the database and copy Label1 to Label42 and wait for the next tick event.

Oxiegen 88 Basically an Occasional Poster Featured Poster

I compared all of your multiple methods.
And through them all, there was one constant value in the form of Label42.Text.
I figured that either
a) you made a typo when constructing the formula, or
b) you came up with your own solution
because that would make the formula come up with different answers every time, when compared to the formula I gave you a few days ago.

Also, if you examine the code in the StoreValues method, i call the method PercentIncrease with the various labels as arguments.
That's where value1 and value2 comes from.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Here's a better way.
There's really only need for one timer for the delay, if you set at high enough interval you also wont get any "cross calling" for the Tick event:

Imports System.Data.SqlClient
Imports System.Data
Imports MySql.Data.MySqlClient

Public Class MainForm
    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ReadValues()
        StoreValues()
    End Sub

    Private Sub ReadValues()
        Label1.Text = EthernetIPforSLCMicro1.ReadAny("F16:0")
        Label2.Text = EthernetIPforSLCMicro1.ReadAny("F16:2")
        Label13.Text = EthernetIPforSLCMicro1.ReadAny("F15:0")
        Label14.Text = EthernetIPforSLCMicro1.ReadAny("F15:1")
        Label15.Text = EthernetIPforSLCMicro1.ReadAny("F15:2")
        Label16.Text = EthernetIPforSLCMicro1.ReadAny("F15:3")
        Label17.Text = EthernetIPforSLCMicro1.ReadAny("B13/16")
        Label18.Text = EthernetIPforSLCMicro1.ReadAny("B13/17")
        Label19.Text = EthernetIPforSLCMicro1.ReadAny("B13/18")
        Label20.Text = EthernetIPforSLCMicro1.ReadAny("B13/19")
    End Sub

    Private Sub StoreValues()
        Dim MySQLConn As MySqlConnection = Nothing 'The SQL Connection
        Dim MySQLCmd As MySqlCommand = Nothing 'The SQL Command
        Try
            Dim connStr As String = "server=xxxx; user id=xxxx; password=xxxx; database=xxxx; pooling=false"
            Dim SQLStr As String

            'SQL Staments
            If PercentIncrease(Label1.Text, Label42.Text, Label42.Text) Then
                'SQL query = myQuery = "SQL Statment"
                SQLStr = "INSERT into xxxxx(id, f16_0, t_stamp) VALUES(' ','" & Label1.Text & "','" & Now() & "')"
            ElseIf PercentIncrease(Label2.Text, Label41.Text, Label42.Text) Then
                'SQL query = myQuery = "SQL Statment"
                SQLStr = "INSERT into xxxxx(id, f16_2, t_stamp) VALUES(' ','" & Label2.Text & "','" & Now() & "')"
            ElseIf PercentIncrease(Label13.Text, Label30.Text, Label42.Text) Then
                'SQL query = myQuery = "SQL Statment"
                SQLStr = "INSERT into xxxxx(id, f16_2, t_stamp) VALUES(' ','" & Label13.Text & "','" & Now() & "')"
            ElseIf PercentIncrease(Label14.Text, Label29.Text, Label42.Text) Then
                'SQL query = myQuery = "SQL Statment"
                SQLStr = "INSERT into xxxxx(id, f16_2, t_stamp) VALUES(' ','" & Label14.Text & "','" & Now() & "')"
            ElseIf …
Oxiegen 88 Basically an Occasional Poster Featured Poster

If this has been helpful, please mark this thread as solved.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Why do you need a timer?

Remove the line Timer.Start() in ElseIf (i = 2) Then and replace the line Timer.Stop() in ElseIf (i = 3) Then to say WebBrowser1.Navigate("http://blogger.com") instead, and do the same in the next two ElseIf statements as well but to navigate to Yahoo.com.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Control arrays is almost non-existant in .NET, so therefore I replaced the label array and the List control with a DataGridView.

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   Dim path As String = Application.StartupPath & "\Test_data.csv"
   Dim stream As System.IO.FileStream = Nothing
   Dim reader As System.IO.TextReader = Nothing
   Dim dt As New DataTable
   Dim headers() As String

   Try
      If System.IO.File.Exists(path) Then
         stream = New System.IO.FileStream(path, FileMode.Open, FileAccess.Read)
         reader = New System.IO.StreamReader(stream)

         While reader.Peek > 0
            line = reader.ReadLine()
            If lineNumber = 0 Then
               headers = line.Split(",")
               For i As Integer = 0 To headers.Length -1
                  dt.Columns.Add(headers(i), GetType(String))
               Next
            Else
               dt.Rows.Add(line.Split(","))
            End If
            lineNumber += 1
         End While
         reader.Close()
         stream.Close()

         DataGridView1.DataSource = dt
      End If
   Catch ex As Exception
      reader = Nothing
      stream = Nothing
   End Try
End Sub

Good luck!

Oxiegen 88 Basically an Occasional Poster Featured Poster

If this was helpful, please mark this thread as solved.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Here's a code snippet for calculating an increase in percent.
For example, an increase from 2 to 10 equals 400%.

Private Function PercentIncrease() As Boolean
   Dim value1 As Double   'Value from database
   Dim value2 As Double   'Value from device
   Dim calc As Double
   
   calc = ((value2 - value1) / value1 * 100)

   If calc > 5 Then
      Return True
   Else
      Return False
   End If
End Sub
Oxiegen 88 Basically an Occasional Poster Featured Poster

Try this:
After Call ChangeRes(1280, 1024) , add the line Me.WindowState = FormWindowState.Maximized .

Oxiegen 88 Basically an Occasional Poster Featured Poster

In all honestly, I have no experience with what you're attempting.
But I am fairly competent in using Google, and applying what I learn from there in my own projects.

Have you read this MS article? Getting WYSIWYG Print Results from a .NET RichTextBox

Oxiegen 88 Basically an Occasional Poster Featured Poster

It's not a very nice thing to do really.
What if the users monitor happens to not support that resolution?
It would be more beneficial to adjust your program to be more dynamic instead.

But if you insist: Here's how

Oxiegen 88 Basically an Occasional Poster Featured Poster

The image is most likely stored as a byte stream in the database.
You have to read the image from the database into a byte array.
From there, you can read the byte array into a memory stream, which in turn is used to call: Image.FromStream(.....)

nick.crane commented: If you check the code this is clearly not the case! +0
Oxiegen 88 Basically an Occasional Poster Featured Poster

Perhaps one of these projects can be useful.
http://www.codeproject.com/KB/printing/

Oxiegen 88 Basically an Occasional Poster Featured Poster

You're welcome.
Please mark the thread as solved.

Oxiegen 88 Basically an Occasional Poster Featured Poster

My bad.
I forgot to include the Software node. And I just read that registry settings for 32bit programs running on Windows x64 are stored in yet anothor subnode.

Try this path: Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("\\Software\\Microsoft\\Windows\\WOW6432node\\CurrentVersion\\Uninstall");

kvprajapati commented: Solved!!! +10
Oxiegen 88 Basically an Occasional Poster Featured Poster

Appearently, Vista/Windows7 doesn't like running Click-Once deployed applications in an elevated UAC.
I found this workaround though, if this is something you might consider: http://www.geektieguy.com/2007/08/25/getting-vista-uac-elevation-to-work-for-web-deployed-clickonce-applications/

Oxiegen 88 Basically an Occasional Poster Featured Poster

See if this helps.

private string WampInstallPath()
{
    Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("\\\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
    Microsoft.Win32.RegistryKey sk = null;
    string path = "";

    foreach (string subkey in rk.GetSubKeyNames())
    {
        if (subkey.ToLower().StartsWith("wamp"))
        {
            sk = rk.OpenSubKey(subkey);
            path = (string)sk.GetValue("InstallLocation");
            break;
        }
    }
    return path;
}
Oxiegen 88 Basically an Occasional Poster Featured Poster

So it's actually a CSV file.
Try this:

private void PopulateDataGridView()
{
    string filePath = "<path to dat file>";
    System.IO.TextReader reader = new System.IO.StreamReader(filePath);
    bool colAdded = false;
    DataTable table = new DataTable("data");

    try
    {
        while (reader.Peek() != -1)
        {
            string[] tokens = System.Text.RegularExpressions.Regex.Split(reader.ReadLine(), ",");
            if (!colAdded)
            {
                foreach (string token in tokens)
                {
                    table.Columns.Add(token);
                }
                colAdded = true;
            }
            else
            {
                DataRow row = table.NewRow();
                for (int i = 0; i < table.Columns.Count; i++)
                {
                    row[i] = tokens[i];
                }
                table.Rows.Add(row);
            }
        }

        dataGridView1.DataMember = "data";
        dataGridView1.DataSource = table;
    }
    finally
    {
        if (reader != null)
            reader.Close();
    }
}
Ketsuekiame commented: Well fed +0
Oxiegen 88 Basically an Occasional Poster Featured Poster

You need to change the projects manifest file a bit.

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <applicationRequestMinimum>
        <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
        <defaultAssemblyRequest permissionSetReference="Custom" />
      </applicationRequestMinimum>
      <!-- Add these lines if missing, else change level from 'AsInvoker' to 'requireAdministrator' -->
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v2">
        <!-- UAC Manifest Options -->
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</asmv1:assembly>
Oxiegen 88 Basically an Occasional Poster Featured Poster

Perhaps you should take a look at XML files.
You can both import and export them into a datatable for manipulation.

Oxiegen 88 Basically an Occasional Poster Featured Poster

That errormessage indicates that something's hinky with the database file itself.
I found this articel in the MS KB.
http://support.microsoft.com/kb/184988

Oxiegen 88 Basically an Occasional Poster Featured Poster

You can use Application.StartUpPath when working with folders originating from the application folder.
Application.StartUpPath gives you the full path for the application executable without the executable file.

Then it's a simple matter of string concatination.

Dim fileName As String = Application.StartupPath & "\subfolder\filename.txt"
Oxiegen 88 Basically an Occasional Poster Featured Poster

Did you create that database folder inside your projectfolder?
Did you move the database file into that folder?
Did you include that folder in your project?
Does the path part of the connectionstring start with a dot slash (.\)?

Oxiegen 88 Basically an Occasional Poster Featured Poster

The computer already installed with MS Access. But it is a trial version which already expired. will this affect to my software?

It doesn't matter. You can uninstall it.

my connection string is like this : "|DataDirectory|\RMA.accdb"

Then your connectionstring should look something like this:

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=.\DataDirectory\RMA.accdb;Persist Security Info=False;

If you get any problems with the connectionstring, then have a look at this: ConnectionStrings.com

Oxiegen 88 Basically an Occasional Poster Featured Poster

Here's an idea I posted in another thread.
Create a folder in your project folder and put the access database file in it.
Then, include that folder in your project.

Use that folder as a reference in the connection string: ".\<databasefolder>\<database file>", instead of "C:\<somefolder>\<databasefile>". (Notice the dot in the beginning).

When you rebuild the project, that folder containing the database file will be copied to the build output folder along with the exe.
Then just copy the files and folder to where ever you want.

When you run the program, it will always know that the database is in a sub-folder from where it's running. Be it on a hard-drive or a USB memory stick.

You shouldn't need to install the complete MS Access program in order to make this work.

Oxiegen 88 Basically an Occasional Poster Featured Poster

If you Release-compiled your program, then there is no need to install "vb".
You do, however, need to install the .NET Framework version for which your program is developed with.

Other then that, just make sure that your Access database is in the same folder as your exe.

Oxiegen 88 Basically an Occasional Poster Featured Poster

I understand. Forgive my presumption. :)

Ok. So what does the first error say?
Is excelPathName a valid path and filename?

Oxiegen 88 Basically an Occasional Poster Featured Poster

Yeah. Why not look into OleDb instead?
With OleDb you can treat the Excel file as a Database source, and from there import the information into DataSets and DataTables.
Which in turn can be used as datasource for your DataGridView.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Change this
SELECT TOP 1 DesID FROM dbo.hrEmpDesignation ORDER BY DesID
Into this
SELECT TOP 1 DesID FROM dbo.hrEmpDesignation ORDER BY DesID DESC

This will change the order so that the latest/greatest id will be the one selected.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Very nice. Progress!

I guess now, all you have to do is fidget with the SaveToFile method and try to see what happens if you replace the semi-colon with a comma.
Or see what happens if you first start Excel and open the CSV file from there.

Excel should automatically detect that it is a CSV file your opening and separate the fields into cells.

Oxiegen 88 Basically an Occasional Poster Featured Poster

You're welcome.
Please mark this thread as solved if you have no other questions.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Keep the newest/current version of the project in a database.
Create a Webservice/WCF service that presents that version online and has a file copying method.
Also, create a small Updater utility that goes with your larger project.

Then add a reference in your project to the service, and compare the two version numbers.

If the presented "online"-version is newer, then shut down the system/program and execute the updater utility that copies the new version using the file copying method in the service.

By using a Webservice/WCF you don't have to worry about firewalls, since it's basically normal HTTP-communication.

Oxiegen 88 Basically an Occasional Poster Featured Poster

The ComboBox control has two properties called AutoCompleteMode and AutoCompleteSource.

Change AutoCompleteMode to Suggest and AutoCompleteSource to ListItems.