Begginnerdev 256 Junior Poster

Below you will find a very brute force way or measuring this:

      int CountChars(char cChar, string sString, bool bCaseSensitive)
    {
        if (!bCaseSensitive)
        {
            cChar = Char.ToLower(cChar);
            sString = sString.ToLower();
        }

        if (sString.IndexOf(cChar) == -1)
        {
            return 0;
        }
        else
        {
            int i;
            int iCount = 0;
            int iStart = sString.IndexOf(cChar);

            for (i = iStart; iStart == sString.Length - 1; iStart++)
            {
                if (sString[i] == cChar)
                {
                    iCount++;
                }
            }
            return iCount;
        }   
    }

You can chose to tell the function to check for case sensitivity or not.

EDIT Once I posted this code, I saw it was the C# forum. I have fixed the code.

Begginnerdev 256 Junior Poster

Below you will find a very brute force way or measuring this:

   Private Function CountChar(ByVal c As Char, ByVal sSource As String, ByVal bCaseSensitive As Boolean) As Integer
    Try
        If Not bCaseSensitive Then
            sSource = sSource.ToLower
            c = Char.ToLower(c)
        End If
        Dim istart As Integer = InStr(sSource, c)
        Dim istop As Integer = InStrRev(sSource, c)
        Dim count As Integer = 0

        For i = istart To istop
            'add 1 for index
            If sSource.Contains(c) Then count += 1
            If sSource(i) = c Then
                count += 1
            End If
        Next

        Return count
    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
        Return 0
    End Try
End Function

You will call the code like so:

iCount = CountChar("a"c, sMyString, True)

This will return the number of lower case a's in the string sMyString.

Begginnerdev 256 Junior Poster

Please post the code that is throwing the given error.

Begginnerdev 256 Junior Poster

You are receiving the error due to InputString expecting an integer as a parameter.

I may be confusing you here with this function, but if you paste the whole function into your code - you can skip all of the other loops for the data.

This function can be used in your code as follows:

  For Each row As DataRow In dts.Tables("[Sheet1$]").Rows
        If IsNumeric(row(0)) Then
            If row(0).ToString.StartsWith("98") Then
                Dim cell1, cell3 As String
                Dim col1, col2, col3, col4 As String
                col1 = String.Empty
                col2 = String.Empty
                col3 = String.Empty
                col4 = String.Empty
                cell1 = row(0).ToString
                cell3 = row(2).ToString
                If cell1.Length = 5 Then
                    col1 = cell1.Substring(0, cell1.Length - 3)
                    col2 = cell1.Substring(2, cell1.Length - 2)
                End If
                If cell3.Length = 5 Then
                    col3 = cell3.Substring(0, cell3.Length - 4)
                    col3 = cell3.Substring(1, cell3.Length - 2)
                End If

                'If you need to format col1 then.
                col1 = FormatString(col1)
                'For column 2
                col2 = FormatString(col2)

                DataGridView1.Rows.Add(col1, col2, col3, col4)
            End If
        End If
    Next



Private Function FormatString(ByVal Input As String) As String
    Try
        Dim sTemp As String = Input
        For Each c As Char In sTemp
            If Not IsNumeric(c) Then
                sTemp = sTemp.Replace(c, "-")
            End If
        Next
        If sTemp.Length < 5 Then
            For i = sTemp.Length + 1 To 5
                sTemp &= "-"
            Next
        End If
        Return sTemp
    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in FormatString!")
        Return Input
    End Try
End Function
Begginnerdev 256 Junior Poster

Is the error occuring in the code or is an exception being thrown to you via message box?

If a message box appears, can you please post an image of the error?

Thank you!

Begginnerdev 256 Junior Poster

You can do this in a query if the values that you are looking for are consistant.

For Example:

'This will get the total number of rows.
"SELECT Count(*) FROM tblStudents WHERE MyCol1='MyVal' AND MyCol2='MyVal'"

'This will give a sum
"SELECT Sum(MyColToSum) FROM tblStudents WHERE MyCol1='MyVal' AND MyCol2='MyVal'"
Begginnerdev 256 Junior Poster

This function should return the values that you are wishing to see:

Private Function FormatString(ByVal Input As String) As String
    Try
        Dim sTemp As String = Input

        For Each c As Char In sTemp
            If Not IsNumeric(c) Then
                sTemp = sTemp.Replace(c, "-")
            End If
        Next

        If sTemp.Length < 5 Then
            For i = sTemp.Length + 1 To 5
                sTemp &= "-"
            Next
        End If

        Return sTemp
    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in FormatString!")
        Return Input
    End Try
End Function

You can test this function with the following:

Dim sInput As String = "8157\" 'Should be 8157-
Dim sInput2 As String = "8b5n\" 'Should be 8-5--
Dim sInput3 As String = "6n16"  'Should be 6-16-

MsgBox(FormatString(sInput))
MsgBox(FormatString(sInput2))
MsgBox(FormatString(sInput3))
Begginnerdev 256 Junior Poster

Do you have a field to indicate year in your data?

Maybe a two digit year, or a range of numbers for student ID that is only valid for that year?

You will need some way to keep track of the year in your data if you wish to pull data out by year.

Begginnerdev 256 Junior Poster

Case #1:
I am not sure that I understand this question completely. By using the code above and the sample data given the 4th column should contain 07 when using

 98123 3//// 80706 8357/ 33302 56999

Is this correct or am I misunderstanding you?

Case #2:
For an empty cell, test using String.IsNullOrWhiteSpace.

For example:

'row(1) will be the second column from the DataSet
If String.IsNullOrWhiteSpace(row(1)) Then
    row(1)="Blank"
End If

Case #3:
You will need to get the total length of the string and then append the backslashes accordingly.

For example:

If cell1.Length < 5 Then
    For i = cell1.Length + 1 To 5
        cell1 &= "\"
    Next
End If
Begginnerdev 256 Junior Poster

Try wrapping your div in an UpdatePanel.

This will allow you to update only that part of the page without calling a full postback.

Begginnerdev 256 Junior Poster

This will be a simple File.Move:

IO.File.Move("SourceFilePath", "DestinationFilePath")
Begginnerdev 256 Junior Poster

Have you tried making use of IsNumeric?

For example:

  For Each row As DataRow In dts.Tables("[Sheet1$]").Rows
        If IsNumeric(row(0)) Then
            If row(0).ToString.StartsWith("98") Then
                Dim cell1, cell3 As String
                Dim col1, col2, col3, col4 As String

                col1 = String.Empty
                col2 = String.Empty
                col3 = String.Empty
                col4 = String.Empty

                cell1 = row(0).ToString
                cell3 = row(2).ToString

                If cell1.Length = 5 Then
                    col1 = cell1.Substring(0, cell1.Length - 3)
                    col2 = cell1.Substring(2, cell1.Length - 2)
                End If

                If cell3.Length = 5 Then
                    col3 = cell3.Substring(0, cell3.Length - 4)
                    col3 = cell3.Substring(1, cell3.Length - 2)
                End If

                DataGridView1.Rows.Add(col1, col2, col3, col4)
            End If
        End If
    Next
zelrick commented: Thank you Sir, IsNumeric solve the "98" problem +1
Begginnerdev 256 Junior Poster

Without seeing your data we can not answer the question effectively.

One method would be to write queriest to select the data you wish to receive based on a date field.

For Example:

'For 2014-2015
"SELECT * FROM MyTable WHERE MyDateCol BETWEEN '01/01/2014 01:01:01' AND '12/31/2014 23:59:59'"

'For 2015-2016
"SELECT * FROM MyTable WHERE MyDateCol BETWEEN '01/01/2015 01:01:01' AND '12/31/2015 23:59:59'"
Begginnerdev 256 Junior Poster

Your question is quite a bit incomplete.

Please provide us with the following information so that we can help you find a solution! =)

What control are you displaying your data in?

Are you wanting to format this data a certain way?

Have you attempted this thus far?

Even with these simple questions, may I make a 30,000ft question?

Have you attemped writing ReportViewer Reports (RDLC)?

Begginnerdev 256 Junior Poster

This is a shell function called SHFileOperation.

Here is an article that you might want to read over.

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

In the NewWindow event of the browser control, you can use the following code:

e.Cancel = True
WebBrowser1.Navigate(New URI(DirectCast(sender, WebBrowser).StatusText))

This will force the active web browser to navigate to the clicked item.

Begginnerdev 256 Junior Poster

Just an additional note: if using OleDB then your queries will need to have '?' instead of a paramter name.

For example:

cmd.CommandText="INSERT INTO tblMyTable (someString,someDate,someNumber) VALUES (?,?,?)"
cmd.Parameters.AddWithValue("@someString",MyStringValue)
cmd.Parameters.AddWithValue("@someDate",MyDateValue)
cmd.Parameters.AddWithValue("@someNumber",MyNumberValue)

cmd.ExecuteNonQuery()
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

Hello and Welcome!

Begginnerdev 256 Junior Poster

Other than upgrading the memory a little, I see no problem using xUbuntu.

You may want to go up to 4gb if possible.

Begginnerdev 256 Junior Poster

Most mother boards have a crash free bios that has a backup of the OEM bios settings. I am assuming you have attempted to boot the pc in safe mode and scan it that way. I suggest booting into a linux live environment to disinfect the problem drive. Something like this might do the trick.

Begginnerdev 256 Junior Poster

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

Begginnerdev 256 Junior Poster

A few questions would be:

What carrier?
Do you want external storage?
Do you prefer a certain OS?

Elvi commented: I prefer android os +0
Begginnerdev 256 Junior Poster

There are a lot of opinions when it comes to work stations.

As far as your graphics card goes; any pci-x 2.0 (x16 for full usage) motherboard will work with it.

The rest will be building the pieces.

As far as chosing a processor for your workstation, you might want to look at current benchmarks.

You will want to try to chose your processor before chosing your motherboard (with socket and age in mind).

All that being said; a lot of workstations that I have build have "Server" processors in them.

Take an Intel Xeon e5 for example.

Begginnerdev 256 Junior Poster

I guess I need to work on my reading comprehension. I completely misunderstood the question and focused on emending the form.

My Apologies

Begginnerdev 256 Junior Poster

You could try pressing Control + F11 on boot to open the DELL recovery utility.

Begginnerdev 256 Junior Poster

After reading over a few documents with HP; I have not discovered any solutions that stand out.

You might want to give this a try to see if it finds something.

Begginnerdev 256 Junior Poster

You can absolutely run a 32bit os on a 64bit processor. (I assume you mean processor)

The advantages of 64bit operating systems are large. For instance; a much larger memory bank is possible on 64bit operating systems.

If a 32bit OS is the only thing available then I'd say go for it. You just may not get full usage of your hardware.

Begginnerdev 256 Junior Poster

I know it sounds extremely simple, but have to tried clearing temp files?

Something as simple as CCleaner might help you do this.

Begginnerdev 256 Junior Poster

First thing is that when you formatted the hard drive you effectively 'removed' everything that was on the drive. This is why you are receiving the "no bootable device" error. There is not an operating system on the drive that can bootstrap it's self.

As for why it is not showing mounted when you connect it to another computer, you may have a driver missing on the second computer that allows that external enclosure to mount.

You will have to aquire a legitimate copy of an operating system. If you are currently seeking a free alternative; I would suggest linux.

There are many different flavors (distros) of linux to chose from. If you are not completely certain which to try then I would recommend Ubuntu. From my experience it has been stable and pretty user friendly compared to some of the others. But that is a bias opinion! :)

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

You can embed a form in another form by placing the child form on a panel!

For example:

Dim frmMain As New MainForm
frmMain.FormBorderStyle = Windows.Forms.FormBorderStyle.None
frmMain.WindowState = Windows.Forms.FormWindowState.Maximized
frmMain.TopLevel = False
pnlMyPanel.Controls.Add(frmMain)
frmMain.Show()
Begginnerdev 256 Junior Poster

What is most likely happening is that you are exiting the main thread when you use Alt+F4; thus no code will fire the code to 'jam' the keyboard.

Begginnerdev 256 Junior Poster

This is absolutely possible! It will all depend apon your coding skills!

It would be just as simple as connecting to the multiple databases at once. Possibly even using threads for data manipulation.

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

What error are you receiving? Also, can you possibly post the code that is throwing the error?

Also with MySQL you may also need to make sure that the connector is installed.

Here is the connector.

Begginnerdev 256 Junior Poster

I currently do not have any screen capture software, but I will try to explain it for you.

 Dim con As New OleDb.OleDbConnection("Provider=127.0.0.1;Data Source=mydb;" & _
 "User Id=myUsername;Password=myPassword;")

What this line does is create an object that will connect to the database. The parameters above are: Provider, Data Source, User ID, and Password.

These Paramters break down as follows:

Provider - The Server that is hosting the database (If a local use 127.0.0.1)
Data Source - The name of the database that you are targeting
User ID - A user that has access to that database (Set up through MySQL)
Password - The user's password (Set up through MySQL)

con.Open()

This line is opening the connection to the database.

Dim cmd As New OleDb.OleDbCommand("INSERT INTO Students(LastName,FirstName,MiddleName) OUTPUT INSERTED.StudentID VALUES(?,?,?)", con)

This line is setting the command that you are issuing to the database.

The command is telling the database engine to insert a new record into the table named Students. The command is also telling the database engine that you are supplying the LastName, FirstName, and MiddleName column values. These columns are set up in the database when you create the Students Table.

The "OUTPUT" Clause tells the command that you wish to retreive the ID of the student that you just inserted.

The Values clause tells the database engine that the column values that you have specified before are about to follow.

Please read this for more …

Begginnerdev 256 Junior Poster

The foremost issue to resolve would be to find what the IP will be for the connection string. The rest will be syntax.

For your correct connection string see this.

Now, for example:

   Protected Friend Function Insert(sFirstName As String, sLastName As String, sMiddleName As String) As Integer
        'Replace home address with IP for hosting server
        Dim con As OleDb.OleDbConnection("Provider=127.0.0.1;Data Source=mydb;" & _ 
                                         "User Id=myUsername;Password=myPassword;")
        Try
            con.Open()
            Dim cmd As New OleDb.OleDbCommand("INSERT INTO Students(LastName,FirstName,MiddleName) OUTPUT INSERTED.StudentID" & _
                                                                   " VALUES(?,?,?)", con)

            cmd.Parameters.AddWithValue("@LastName", IIf(sLastName = String.Empty, DBNull.Value, sLastName))
            cmd.Parameters.AddWithValue("@FirstName", IIf(sFirstName = String.Empty, DBNull.Value, sFirstName))
            cmd.Parameters.AddWithValue("@MiddleName", IIf(sMiddleName = String.Empty, DBNull.Value, sMiddleName))

            'Returns the inserted student's ID
            Return CInt(cmd.ExecuteScalar)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Student.Insert")
            Return -1
        Finally
            con.Close()
        End Try
    End Function

Now you can insert a student like so:

If Insert("John","Doe","Lotta") > 0 Then
    'Inserted
Else
    'Did not insert
End If
Begginnerdev 256 Junior Poster

Will the server that you are connecting to have a static IP?

Also, what database type are you connecting to?

SQL Server, Oracle, MySQL, Access, ect...

Begginnerdev 256 Junior Poster

One java book that was always a great resource when I had begun school was the Java Programmer's Bible.

Begginnerdev 256 Junior Poster

As you may already know. Most Printers support the TWAIN interface. Most printers also support WIA.

This being said, you could use a TWAIN or WIA library to access your scanner (Pending drivers are installed).

See attached file for code for a scanning library! (Courtesy of Mkasoft)

Place the code in a codefile and compile it into a library, then add that library reference to your project.

To use the code, try:

Private sMyScanner As String = String.Empty

Private Sub btnSelectSource_Click(sender As System.Object, e As System.EventArgs) Handles btnSelectSource.Click
    'Set the scan source for your scan.
    sMyScanner = TwainLib.GetScanSource
End Sub

Private Sub btnScan_Click(sender As System.Object, e As System.EventArgs) Handles btnScan.Click
    'Scan images from source and place the file path in a list of string for later access.
    Dim lstFiles As List(Of String) = TwainLib.ScanImages(".bmp", True, sMyScanner)
End Sub
Begginnerdev 256 Junior Poster

After a quick google session, I have discovered this article.

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

One question would be: Are you populating the listview from a database? If so, then just create a report with that dataset instead of trying to get the data from the listview.

Begginnerdev 256 Junior Poster

Quite a simple solution to your problem would be to write a query that does so!

For example:

Private Sub Button1_Click(ByVal sender as Object, ByVal e As EventArgs) Handles Button1.Click
   Dim con As New OleDBConnection("YourConnectionStringHere")
   Dim cmd As New OleDBCommand("UPDATE table1 SET col2=? WHERE col1=?",con)
   Try
      'When using OleDB you must use ? for the parameter.
      'When using other libraries use @parameter to name them.   
      cmd.Parameters.AddWithValue("@val",ValueToInsert)
      cmd.Parameters.AddWithValue("@myUniqueVal",UniqueValue)

      'Once added, the query will look like:
      ' UPDATE table1 SET col2=ValueToInsert WHERE col1=UniqueValue
      con.Open
      cmd.ExecuteNonQuery()
   Catch ex As Exception
      MsgBox(ex.Message)
   End Try
End Sub
Begginnerdev 256 Junior Poster

Please read the community rules here.

You will have to provide some form of proof that you have indeed attempted this assignment.

We are not here to complete your work, but to possibly help troubleshoot code that might also lead to a better understanding.

Begginnerdev 256 Junior Poster

Can you please post your connection code?

We will need to see (if possible) your code to help with the debugging process.

I also assume you have the correct connection strings and such.

If not, see this please.

Begginnerdev 256 Junior Poster

Can you please post your connection string to your database?

Also, Have you given the correct permissions in Workbench?

Begginnerdev 256 Junior Poster

Have you tried calling BringToFront?