Begginnerdev 256 Junior Poster

A SELECT CASE would look something like:

Select Case Mid(txtLine, 18, 1)
    Case "G", "T", "C", "W"
        'Do this stuff only for those
    Case Else
        'Do some stuff
End Select

Here is an article that might help you get a little better understanding.

Begginnerdev 256 Junior Poster

Q: What do you call a dog which has no legs?
A: Anything you want; he's still not coming to you.

tobyITguy commented: Lmao!! +0
Begginnerdev 256 Junior Poster

Please post the code that you have in your fol_hide_load procedure.

Begginnerdev 256 Junior Poster

Have you tried replacing:

Dim csCryptoStream As CryptoStream

With

Dim csCryptoStream As New CryptoStream

What this warning is telling you is that the variable could throw a null reference exception if there is a dependant variable that requires instantiation. By not declaring the variable with the New modifier, you are possibly not creating any dependant arrays, variables, objects, ect....

Begginnerdev 256 Junior Poster

Try declaring an integer value at the class level:

Dim iCount as Integer = 0

Then increment on removal:

If listItem.SubItems.Item(0).Text = " " Or listItem.SubItems.Item(0).Text = "" Then
    ListView1.Items.Remove(listItem)
    iCount += 1
End If

Once finished print out the count:

If iCount > 0 Then
    MsgBox("Clearing completed." & iCount & " Lines were removed.")
End If
Begginnerdev 256 Junior Poster

May I suggest a safer method of storing a password?

You could create a database in something as simple as access and store the passwords in a table.

To increase the security further, you can encrypt the passwords and store the encrypted string into the database.

This method is called trap door encryption.

(Example uses Microsoft's example found here)
(Example uses Access 2010 and Visual Studio 2010)
(Example connection code uses System.Data.OleDB)

For example:

Imports System.Security.Cryptography 
Public Class Encryption
    Private TripleDes As New TripleDESCryptoServiceProvider

    Sub New(ByVal key As String)
        ' Initialize the crypto provider.
        TripleDES.Key = TruncateHash(key, TripleDES.KeySize \ 8)
        TripleDES.IV = TruncateHash("", TripleDES.BlockSize \ 8)
    End Sub

    Private Function TruncateHash( ByVal key As String, ByVal length As Integer) As Byte()
        Dim sha1 As New SHA1CryptoServiceProvider

        ' Hash the key. 
        Dim keyBytes() As Byte =
            System.Text.Encoding.Unicode.GetBytes(key)
        Dim hash() As Byte = sha1.ComputeHash(keyBytes)

        ' Truncate or pad the hash. 
        ReDim Preserve hash(length - 1)
        Return hash
    End Function

    Public Function EncryptData(ByVal plaintext As String) As String

        ' Convert the plaintext string to a byte array. 
        Dim plaintextBytes() As Byte =
            System.Text.Encoding.Unicode.GetBytes(plaintext)

        ' Create the stream. 
        Dim ms As New System.IO.MemoryStream
        ' Create the encoder to write to the stream. 
        Dim encStream As New CryptoStream(ms,
            TripleDes.CreateEncryptor(),
            System.Security.Cryptography.CryptoStreamMode.Write)

        ' Use the crypto stream to write the byte array to the stream.
        encStream.Write(plaintextBytes, 0, plaintextBytes.Length)
        encStream.FlushFinalBlock()

        ' Convert the encrypted stream to a printable string. 
        Return Convert.ToBase64String(ms.ToArray)
    End Function

    Public Function DecryptData(ByVal encryptedtext As String) As String

        ' Convert …
Santanu.Das commented: High antibiotics for a simple temperature +4
Begginnerdev 256 Junior Poster

If the array is placed in the same codefile as the events, then public/shared modifiers are not needed.

May I suggest a list?

Dim array_shuffle As New List(Of Integer)

Lists are a class that implements the IEnumerable interface.
Therefore, you will have the ability to sort,search,add,remove and event use LINQ statements on the list.

   array_shuffle.Sort(MyIntComparer)
   array_shuffle.Add(101) 'Will add an item to the list with the value of 101
   array_shuffle.Remove(101) 'Will remove the entry of value 101

   Dim query = From iVal In array_shuffle
               Where iVal > 100
               Select iVal

   query.ToArray() 'Will return an integer array containg all values that are larger than 100.

As for comparison help please see this.

Begginnerdev 256 Junior Poster

You will first need to return the ID of the inserted row and store that in a variable.

Next you will need to issue the update the row using that variable.

For example:

Private Sub InsertAndUpDate()
    Dim con As New OleDBConnection("MyConnectionStringHere")
    Try
        con.Open()
        Dim cmd As OleDBCommand("INSERT INTO tblTest(Col1,Col2) OUTPUT Inserted.MyID VALUES ('Col1 vals', Col2 vals')",con)
        Dim iInsertedID  As Integer = - 1
        iInsertedID = Cint(cmd.ExecuteScalar)

        If iInsertedID > -1 Then

            cmd.CommandText = "UPDATE tblTest SET Col1='MYVAL 1' Col2='MYVAL 2' WHERE MyID=" & iInsertedID

            cmd.ExecuteNonQuery()

            MsgBox("Record inserted and updated!")
        End If
    Catch ex As Exception
        MsgBox(ex.ToString)
    Finally
        con.Close()
    End Try
End Sub
Begginnerdev 256 Junior Poster

Have you copied/pasted the query directly to your dbms?

Are you sure that it is not returning any rows?

When possible, I liked to write the query in the dbms then rewrite it in code.

Begginnerdev 256 Junior Poster

If you wish to only select the month portion of a date field, you must do the following:

" WHERE (MONTH(pr.[Current Month]) = 6 AND MONTH(al.[Current Month]) = 6 AND MONTH(pd.[Current Month]) = 6"

Here is a the white paper for the MONTH function.

Please note that this applies to SQL 2005 +

Begginnerdev 256 Junior Poster

After a quick google session using keywords I found this article. Maybe it is what you are looking for! :)

Begginnerdev 256 Junior Poster

You can condense your query a little by giving your select tables an alias.

For example:

"INSERT INTO patempTable SELECT pr.[Project Number],pr.[Employee Number],pr.[Current Month],pr.[Net Pay],al.[Net Allowance], pd.[Net] FROM [Pay_roll] pr, [Allowance] al, [Per_diem_accomodation]"

Now for tieing the tables together, my question would be: Are there multiple 'P' codes or are you just wanting to select where everything matches?

If you are just wanting to select where everything matches you can simply do something like this:

" WHERE (pd.[Project Number] = al.[Project Number] AND al.[Project Number] = pr.[Project Number])"

The ambiguity comes in with the selection by month/year.

You can try to wrap these statements with parenthesis for qualification.

For example (When added to strings above):

" AND (pr.[Current Month] = '6' AND al.[Current Month]='6' AND pd.[Current Month]='6')"
Begginnerdev 256 Junior Poster

Excel is formatting the number. Open excel and set the desired format for those columns.

First select the column:

2c3a3bd75a4df2f9283ee563f1501fb8

Next set the formatting:

c536ebac45fe03bdcf1984565daa2667

Click okay and you are finished!

791f2d76ccfad3d9ab0d7bd1870f9663

Begginnerdev 256 Junior Poster

If your motherboard has an onboard video, you might want to try running through onboard to get a confirmation on a possible bad GPU. As for the dust bunnies, you can set your case fan configuration to allow negative pressure. I use this technique personally and it works great, aside from having to clean the fans once or twice a month.

(Setup using 12x120mm fans and 1 240mm fan)

Begginnerdev 256 Junior Poster

If it is a video card, the computer would still power up.

My thought is that it might be an overheated processor. It could have been a possible bad bearing in the fan, causing less airflow resulting in a frying pan for a processor.

You had said that you have a beefy fan/heatsink on the processor, have you tried un-mounting it from the board and checking the processor for any visual blemishes?

Begginnerdev 256 Junior Poster

Sorry for the hiatus.

Have you checked to verify if the correct number of BUTTONX Outputs exists?

For example, press button one 3 times then press button two 3 times.

Or is the output returning empty string on some of the button presses?

Begginnerdev 256 Junior Poster

Are you using an interpreter on your Arduino? If not, then this should be posted in the C++ forum.

Also, you will have to post your code the application if you wish for us to help find your problem! :)

Begginnerdev 256 Junior Poster

You need to look into using the DateDiff Function.

You will receive the day value by passing in the day interval and your two dates.

DateDiff(DateInterval.Day,dtStart,Now()) 'Will return number of days between now and the start date

You can place this function in your check-out code. Just pull in the check-in date and pass in the current date, et viola!

Begginnerdev 256 Junior Poster

Hello!

Please elaborate as to which programming language you are using. There are many ways to count the number of days between two dates, but we can not give any if we don't know your desired language!

Begginnerdev 256 Junior Poster

Here is a VERY OLD article that does this exact thing.

Begginnerdev 256 Junior Poster

You might have to set your command for the update:

da.UpdateCommand = New OleDBCommandBuilder(da).GetUpdateCommand()

Then issue the update.

See if this helps.

Begginnerdev 256 Junior Poster

As for CSV, it does not matter what application is writing - it is the format of the data that qualifies it for a CSV. See this. (Yes, I know it is Wikipedia.)

If you are needing the file to be unreadable to an unautherized user then you should look into file serialization.

This can be used to serialize the file and only access it from the application. This will not stop a user from deleting the file if they do happen to find it.

Just don't name it "YourApplicationName History".

If you are wanting to retreive the top 10/20/50 records - just modify the code to reflect this:

Dim iRecordCount As Integer = 1
While sr.Peek <> -1
    lstStrings.Add(sr.ReadLine.Split(",").ToList)
    iRecordCount += 1
    If iRecordCount = iNumberOfRecords Then Exit While
End While

This will get the oldest 10/20/50 (Entries are stored in a FIFO method.)

If you want the newest 10/20/50 you will have to change the code that populates the listview:

Dim iRecordCount As Integer = 1
For Each lst As List(Of String) In lstHistory

    Dim lvi As New ListViewItem
    lvi.Text = lst(0) 

    lvi.SubItems.Add(lst(1))
    ListView1.Items.Add(lvi)

    iRecordCount += 1
    IF iRecordCount = iNumberOfRecords Then Exit For
Next

Either way, it is a simple refactor/recode.

Begginnerdev 256 Junior Poster

When you say that you are saving the data in the settings, are you referring to application settings? If so, then this will be an extremely inefficient method of storage.

Why not store the history in a csv? (If the data is not confidential!)

Then you could load your listview with the data from the CSV.

When saving, create a small function to write to the file and return a value.

For example:

Private Function SaveHistoryItem(ByVal sDateString As String, ByVal dTimeOfDay As DateTime) As Boolean
    Try
        Dim fp As String = My.Settings.FilePath 'String variable in Application settings containing the full path to the CSV File

        'Check if the file exists, if not, create it.
        If Not File.Exists(fp) Then File.Create(fp)

        Dim sw As New StreamWriter(fp, True)

        'Formats the data:
        '01/20/2013,11/21/2013 14:36:04'
        sw.WriteLine(sDateString & "," & dTimeOfDay.ToString)

        sw.Close()
        sw.Dispose()
        fp = Nothing

        Return True 'SAVED
    Catch ex As Exception
        MsgBox(ex.ToString)
        Return False 'FAILED
    End Try
End Function

You can use a function like this like so:

If SaveHistoryItem("01/01/2013",Now()) Then
    'Clean Up
Else
    'Didn't save, do something!
End If

Now, to load the data, write another small function to retreive the values from the CSV file and to pass them to your form.

For example:

Private Function ReadFromHistory() As List(Of List(Of String))
    Try
        Dim fp As String = My.Settings.FilePath

        If Not File.Exists(fp) Then Return New List(Of List(Of String))

        Dim sr As New StreamReader(fp)
        Dim lstStrings As New List(Of List(Of String))

        While sr.Peek <> -1
            lstStrings.Add(sr.ReadLine.Split(",").ToList)
        End While

        'List …
Reverend Jim commented: Very thorough +12
Deep Modi commented: good suggestion but can you still do something? +3
Begginnerdev 256 Junior Poster

Would something like this:

TabControl1.SelectedTab.Controls.Find("MyRichTextBox", [True])

Be the answer you are looking for?

Just replace the "MyRichTextBox" with the tab title, et voila.

Begginnerdev 256 Junior Poster

Have you checked to see if you are using any depricated features in your function?

Begginnerdev 256 Junior Poster

Is it possible that the message box breaks execution long enough for your buffer to catch up?

Begginnerdev 256 Junior Poster

If you think of your screen as a quadrant, it would have the y axis reversed.
(X,Y)
0,0 | 1,0 | 2,0 | 3,0 |
0,1 | 1,1 | 2,1 | 3,1 |
0,2 | 1,2 | 2,2 | 3,2 |

This being said, you see a positive value in debug because you are viewing the values before the interpreter sees the '-'

Begginnerdev 256 Junior Poster

As shown here; the TranslateTransform sets the new zero point of the drawing.

When you call this you are setting the new zero point to the center of the screen. (1/2 sz.Width, 1/2 sz.Height).

Therefore, when you tell it to draw the string at 5,6 it will draw using the new zero.

ddanbe commented: Nice. +14
Begginnerdev 256 Junior Poster

My week normally goes as follows:

Work - Most of the day
Gym - 1 hour 30 minutes
Social Life - What's left

Begginnerdev 256 Junior Poster

Sounds like your problem lies here:

Dim s As String = "SELECT * FROM pay_item_description WHERE [pay item]='" & str & "'"

If you change the code to :

Dim s As String = "SELECT * FROM pay_item_description WHERE [pay item]=" & Cint(str)

Or

Dim s As String = "SELECT * FROM pay_item_description WHERE [pay item]=" & CDbl(str)

What happens?

Begginnerdev 256 Junior Poster

You can try writing a custom fill function:

Private Function Fill(ByVal lstIN As List(Of T)) As Boolean
    Try
        Dim lvi As New ListViewItem

        lvi.Text = lstIN(0) 'if index 0 is a unique - Column 1
        lvi.SubItems.Add(lstIN(1)) 'Column 2 in listview
        lvi.SubItems.Add(lstIN(2)) 'Column 3

        ListView1.Items.Add(lvi)

        Return True
    Catch ex As Exception
        Return False
    End Try
End Function
Begginnerdev 256 Junior Poster

I'd say about 3-4 inches from chest.

We call that "butt to the grass"

Begginnerdev 256 Junior Poster

My routine usually goes as follows:

Average day:
Cardio(Running)
Compound Exercises(By Muscle Group)

Schedule:
Monday - Upper
Tuesday - Lower
Wednesday - Rest
Thursday - Upper
Friday: Lower
Saturday - Touch Up
Sunday - Rest

Chest/Arms:
Bench Press
-Flat
-Incline
-Decline

Curling
-Preacher curls
-Hammer
-Modified Hammer (Twist dumbell when 3/4 into contraction)

Bench Dips

Shoulders/Back:

Facepulls:
-Top down
-Face level
-Bottom up

Rows

Pulldowns
-Font (Bar touches chest)
-Back (Bar touches traps)

Legs:

Legpress:
-Warm up at 700
-3 sets of 15 reps at 1100
Squats:
-Warm up at 205
-3 sets of 15 reps at 450

Running to finish legs off

cproger commented: Wow +0
Begginnerdev 256 Junior Poster

Something as simple as:

Dim sr As New StreamReader("PAthtofile")
While sr.Peek <> -1
    Console.Out.WriteLine(sr.ReadLine)
End While
Begginnerdev 256 Junior Poster

When stepping though the code which part is showing null?

DtSet or Data1?

Begginnerdev 256 Junior Poster

On what line of code is the null reference being thrown?

Begginnerdev 256 Junior Poster

Try changing your fill statement to incorporate a table name:

adpt.Fill(DtSet,"Data1")

Now you can access the table like so:

IF Not IsNothing(DtSet.Tables("Data1")) And DtSet.Tables("Data1").Rows.Count > 0 Then
    'Do work
End If
Begginnerdev 256 Junior Poster

Try changing your class to have a new instance of List(Of Student)

For example:

<Serializable()> _    
Public Class LessonPlans
    Private lstStudents As New List(Of Student)
    Public Property Teacher As String
    Public Property RoomNumber As String
    Public Property Subject As String
    Public Property Students As List(Of Student)
    Get
        Return Me.lstStudents
    End Get
    Set(value As List(Of Student)
        Me.lstStudents = value
    End Set
End Class

This may be the compilers best way of dealing with an uninstantiated list.

Begginnerdev 256 Junior Poster

When you issue this select command:

"SELECT * FROM Table WHERE 1=2"

You are just retrieving the table structure simply because 1 will never equal 2.

This is a nifty little trick to get your table structure without having to recreate it in code.

Just makes life a little easier. :)

As for the column headers, just set the start of i to 0 and your problem should be solved. :)

For i = 0 To lstAllStrings.Count - 1 'Skip the title row and the empty row
  lstFinalStrings.Add(lstAllStrings(i).Split(" ").ToList)
Next

Just a note, if the spaces are tabs you can change the split from:

.Split(" ")

To

.Split(vbTab)
Begginnerdev 256 Junior Poster

You will want to open a stream reader to the file and pull all lines in from the file. You will then have to remove the spaces from the lines to extract the infromation you want. This can be done like so:

Private Function FillStringList(ByVal sFileName As String) As List(Of List(Of String))
    Dim sr As New StreamReader(sFileName)
    Dim lstAllStrings As New List(Of String)
    Dim lstFinalStrings As New List(Of List(Of String))
    Try
        Do While sr.Peek <> -1
            lstAllStrings.Add(sr.ReadLine())
        Loop

        'Split on spaces
        'Should look something like
        '(0) = 07-24-13
        '(1) = 12:23:52
        '(2) = 001
        '(3) = 07

        For i = 2 To lstAllStrings.Count - 1 'Skip the title row and the empty row
            lstFinalStrings.Add(lstAllStrings(i).Split(" ").ToList)
        Next

        Return lstFinalStrings
    Catch ex As Exception
        MsgBox(ex.ToString)
        Return Nothing
    Finally
        sr.Close()
        sr = Nothing
        lstAllStrings = Nothing
        lstFinalStrings = Nothing
    End Try
End Function


Private Sub InsertToDatabase(ByVal lstStrings As List(Of List(Of String)))
    Dim da As New OleDbDataAdapter(New OleDbCommand("SELECT * FROM Import WHERE 1=2", _
                                   New OleDbConnection("myConnectionSTRINGHERE"))) ' Gets the table structure
    Dim ds As New DataSet

    Try
        da.Fill(ds, "Import")

        If Not IsNothing(ds.Tables("Import")) Then
            For Each item As List(Of String) In lstStrings
                Dim dr As DataRow = ds.Tables("import").Rows.Add()

                dr("Date") = item(0) 'Need fault protection
                dr("Time") = item(1) 'This code sample assumes data will be consistent
                dr("s1") = item(2) 'You will need to put your own handling in
                dr("s2") = item(3) 'This is not guarenteed
                dr("EmpiD") = item(4)
                dr("IN\OUT") = item(5)
            Next

            da.InsertCommand = New OleDbCommandBuilder(da).GetInsertCommand
            da.Update(ds.Tables("Import")) 'Update will issue the insert
        Else
            Exit Sub …
Begginnerdev 256 Junior Poster

Does the DataGridView in the sales form have AutoGenerateColumns enabled while the Purchase does not?

Begginnerdev 256 Junior Poster

Does the local administrator have privelages over the domain, or are there two levels for admin? (Domain and local)

Begginnerdev 256 Junior Poster

If Motor is the name of the class then you might be refrencing an un instantiated object.

For example:

Dim m As New Motor

'm is now instantiated
m.tenLin = 220

MsgBox(m.tenLin) ' Should read out 220

I hope this helps

Begginnerdev 256 Junior Poster

By seeing this code, I assume that you are using a form of data hiding.

That being said, the code posted works and should not create such a problem by its self.

Run a find all references and see where else the value is getting changed for your string.

Begginnerdev 256 Junior Poster

Are you programming in WPF or Winforms?

Begginnerdev 256 Junior Poster

Just a curiosity. Is the Microsoft folder an admin only folder,and you happen to be a restricted user?

Begginnerdev 256 Junior Poster

Have you tried cycling through the code in debug to see what the log names are?

Just place a break point before the loop, step into the loop (F11) then hover over the entry variable.

(You should change it to For Each e As Entry in objLog)

Begginnerdev 256 Junior Poster

I took us a good week to iron out all of the problems.

That mde has been phased out though. We replaced it with a .net application 4 months later.

Begginnerdev 256 Junior Poster

Would something like this work:

FormatNumber(CInt(1000 + 2.6 + 3.5)), 2)

Just let the framework do the formatting for you.

Begginnerdev 256 Junior Poster

Here is a decent article on Windows services.

As for as deployement, does 2013 include ClickOnce?