cgeier 187 Junior Poster
cgeier 187 Junior Poster

How to: Save, Load, and Print RichTextBox Content

Note: Notepad doesn't handle rich text. WordPad does though.

cgeier 187 Junior Poster

The following has been tested and should work:

Requires the following:

Add reference to "Microsoft Word xx.x Object Library":

  • Click "Project"
  • Select "Add Reference"
  • Click "COM" tab
  • Select "Microsoft Word xx.x Object Library"

Add import statements:

  • Imports System.Runtime.InteropServices
  • Imports Word = Microsoft.Office.Interop.Word

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
        'use early binding
        Dim objWordApp As Word.Application = Nothing
    
        Try
    
            objWordApp = New Word.Application
    
            'Open an existing document.
            objWordApp.Documents.Open("C:\Temp\Sample.docx")
    
            'copy data to clipboard
            RichTextBox1.SelectAll()
            RichTextBox1.Copy()
    
            'find <address>
            objWordApp.Selection.Find.Execute("<address>")
    
            'copy richtext from clipboard
            objWordApp.Selection.PasteSpecial(DataType:= Word.WdPasteDataType.wdPasteRTF)
    
            'clear the clipboard
            Clipboard.Clear()
    
            'Save and close the document.
            objWordApp.Documents.Item(1).Save()
            objWordApp.Documents.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
    
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
    
            'quit Word
            If Not IsNothing(objWordApp) Then
                objWordApp.Quit()
                objWordApp = Nothing
            End If
    
        End Try
    End Sub
    

*Note: The font properties will be transferred from the RichTextBox as well.

Resources:
Find.Execute Method (Word)

  • ReplaceWith: "...To specify a graphic object or other nontext item as the replacement, move the item to the Clipboard..."

Selection.PasteSpecial Method (Word)

How to: Programmatically Search for and Replace Text in Documents

Transfer formatted RichTextBox into Microsoft Word

Word Object Model Overview (2010)

Word Object Model Reference

cgeier 187 Junior Poster

Check your recycle bin to see if it is there. Otherwise you may be able to recover the file using data recovery software. You will want to stop using the drive that contains the data until you recover the file, as further usage may overwrite the file that you are trying to recover.

Also, this is not really a vb issue, but rather a deleted file / data recovery issue.

In the future, ensure that you have a backup solution in place so that your files are backed up.

cgeier 187 Junior Poster

Does this happen only on one radio station, or all radio stations?

Check your buffering settings.

  • Open Media Player
  • If in "Now Playing" mode, click on "Go to Library".
  • Press Ctrl-M, to show menu bar (or right-click in empty menu area and select "Show menu bar".
  • Click "Tools"
  • Select "Options"

  • Click "Performance" tab

What are your settings for:

  • Connection speed?
  • Network buffering? (You can try selecting "Buffer" and entering "30"--or any number from 1-60--seconds of content)

  • Click "Network" tab

  • Which boxes are checked for "Protocols for MMS URLs"?
  • Under "Multicast streams", is "Allow the player to receive multicast streams" checked?

Additionally, if you are using a router, check the QoS (Quality of Service) settings.

cgeier 187 Junior Poster

There is a correction to my above post. There was a typo. Also, the previously mentioned keys are for XP/Win 7 (32-bit). If you are using Win 7 (64-bit), you need to look in the "Wow6432Node"--since Jet 4.0 doesn't have a 64-bit version (Jet 4.0 only exists in a 32-bit version). These keys may also be found in MS server verions. Open a "cmd.exe" window, and run the following commands.

OS:

  • reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v ProductName

or using wmic:

  • wmic os get caption

Architecture:

  • set | find /i "architecture"

or using wmic:

  • wmic cpu get DataWidth

Jet 4.0:
reg query "HKCR\Microsoft.Jet.OLEDB.4.0"

32-bit operating system:

  • reg query "HKCR\CLSID{dee35070-506b-11cf-b1aa-00aa00b8de95}\OLE DB Provider"

  • reg query "HKCR\CLSID{dee35070-506b-11cf-b1aa-00aa00b8de95}\InprocServer32"

  • reg query "HKCR\CLSID{dee35070-506b-11cf-b1aa-00aa00b8de95}\ProgID"

  • reg query "HKLM\Software\ODBC\ODBCINST.INI\ODBC Drivers" | find /i "Microsoft Text Driver"

64-bit operating system:

  • reg query "HKCR\Wow6432Node\CLSID{dee35070-506b-11cf-b1aa-00aa00b8de95}\OLE DB Provider"

  • reg query "HKCR\Wow6432Node\CLSID{dee35070-506b-11cf-b1aa-00aa00b8de95}\InprocServer32"

  • reg query "HKCR\Wow6432Node\CLSID{dee35070-506b-11cf-b1aa-00aa00b8de95}\ProgID"

  • reg query "HKLM\Software\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers" | find /i "Microsoft Text Driver"

cgeier 187 Junior Poster

You may be able to adapt this to use in your program:

How to: Bind Data to the Windows Forms DataGridView Control

The best way for you to learn is to research the issues that you encounter. You will find information that may not be useful to you right now, but one day it may be of use to you. If you are not finding useful information using your favorite search engine, then re-phrase your query--try removing words from your search.

cgeier 187 Junior Poster

Pass the info in the constructor and choose the correct tab using code in the constructor or use form communication--see the tutorial for form comunication.

cgeier 187 Junior Poster

Glad to hear it is working. The registry keys above are for Win 7. They may be different on different OS's.32-bit applications can run on 64-bit machines. However, 64-bit applications can't run on 32-bit machines.

cgeier 187 Junior Poster

Are you using "System.Windows.Forms.WebBrowser"? If so, try the following:

System.Windows.Forms.WebBrowser myWebBrowser = null;

//disable script errors
this.myWebBrowser.ScriptErrorsSuppressed = true;
cgeier 187 Junior Poster

That's because every time your event (TextChanged) occurs you are calling the "Add" method. You should only add the binding if it doesn't already exist.

cgeier 187 Junior Poster

Ensure that the "Shutdown" option is not configured to restart the computer.

  • Right click the "Start button" (Windows globe)
  • Select "Properties"
  • Click "Start Menu"
  • Ensure "Power Button Action" is "Shutdown" (not restart)
cgeier 187 Junior Poster

Also, ensure that your program is compiled only for x86 (not anyCPU). I don't believe that there is a 64-bit version of JET.

Get information about the computer (architecture and OS version):

            if (System.Environment.Is64BitOperatingSystem == true)
            {
                Console.WriteLine("Processor Architecture: 64-bit");
            }//if
            else
            {
                Console.WriteLine("Processor Architecture: 32-bit");
            }

            Console.WriteLine("OS Version: " + System.Environment.OSVersion.ToString());

Alternatively,

In a "cmd.exe" window,

OS version:
* reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v ProductName

Architecture:
set | find /i "architecture"

cgeier 187 Junior Poster

Check the event logs on the server to see if there are any errors. Also add the following Catch (OleDbException e).

Also check that "Jet 4.0" is installed (properly).

  • reg query "HKCR\CLSID{dee35070-506b-11cf-b1aa-00aa00b8de95}\OLE DB Provider"

  • reg query "HKCR\CLSID{dee35070-506b-11cf-b1aa-00aa00b8de95}\InprocServer32"

  • reg query "HKCR\CLSID{dee35070-506b-11cf-b1aa-00aa00b8de95}\ProgID"

  • reg query "HKLM\Software\ODBC\ODBCINST.INI\ODBC Drivers" | find "Microsoft Text Driver"

Adapted from here.

cgeier 187 Junior Poster

Are you running the actual program on the server, or running the program on your computer and trying to access the file on the server?

cgeier 187 Junior Poster

You should not use the "sa" account for database access. You can use it for testing, but it is designed for administrative use.

SqlConnection.ConnectionString Property

If User ID and Password are specified and Integrated Security is set to true, the User ID and Password will be ignored and Integrated Security will be used.

If you want to use domain authentication, grant appropriate permissions as Begginnerdev mentioned.

cgeier 187 Junior Poster

It seems like a no-brainer to develop using the .NET version that you plan on using to run the program, because new features are added in newer versions. Either install .NET 4.5 on the server, or install the .NET version you plan on using to run the program, on your development machine and use that version for your program (v4.0).

cgeier 187 Junior Poster

Check manufacturer website for driver update. If no update exists, re-install the existing driver. Also, try removing from device manager and letting the OS re-install the device.

cgeier 187 Junior Poster

Find the source of failure, and fix it. Or disable updates.

cgeier 187 Junior Poster

This is not an expert with this, but I believe you need to use a programmable microcontroller. Or a pre-built product that contains a microcontroller.

cgeier 187 Junior Poster

Check this site out.

cgeier 187 Junior Poster

I don't think anyone has any idea what you are talking about. What is "real excel"? There are tons of examples on how to create excel files on the net. Present some code, or at least some pseudo code of what you are trying to do.

cgeier 187 Junior Poster

Flickering tends to occur when one re-draws/re-paints the form and/or the controls that are contained on it.

cgeier 187 Junior Poster

Mouse issue:

Try the following:

Turn off hybrid sleep:

  • Control Panel
  • View by: Small Icons
  • Power Options
  • Change Plan Settings
  • Change advanced power settings
  • Expand "Sleep" (by clicking the "+")
  • Expand "Allow hybrid sleep" (by clicking the "+")
  • On battery: Off
  • Plugged in: Off
  • Click "Apply"
  • Click "OK"

Ensure mouse has ability to wake the computer:

  • Control Panel
  • View by: Small Icons
  • Device Manager
  • If prompted: Do you want to allow this device to make changes to the computer? Click Yes.
  • Mice and other pointing devices
  • Right-click your touchpad/mouse and select Properties
  • Click "Power Management" tab
  • Check "Allow this device to wake the computer"
  • Click "OK"

Restart your computer (may or may not be necessary).

cgeier 187 Junior Poster

Also, line #20 should probably be:

printf("Approximate value of PI is %.9f\n", PI);

Changed from %9.f to %.9f and from sum to PI

cgeier 187 Junior Poster

In line #10, you trying to use x, but it has not been initialized (x doesn't have a value).

for (i=1; i<x; i++)

ddanbe commented: keen eye +15
cgeier 187 Junior Poster

Use another do-while loop (ie: use nested do-while loop)

do{

   do{

       ...
       case 1:
       ...
       case 2:
       ...

   }while(....);

}while(....);
cgeier 187 Junior Poster
For Each ctrlItem As Control In Me.Controls
    If TypeOf ctrlItem Is System.Windows.Forms.CheckBox Then
        Dim myCheckBox = CType(ctrlItem, System.Windows.Forms.CheckBox)
        myCheckBox.Checked = True
    End If
Next

Or

Private Sub checkCheckBoxesStartingWith(ByVal startsWithText As String)
    For Each ctrlItem As Control In Me.Controls
        If TypeOf ctrlItem Is System.Windows.Forms.CheckBox Then
            If ctrlItem.Name.StartsWith(startsWithText) Then
                Dim myCheckBox = CType(ctrlItem, System.Windows.Forms.CheckBox)
                myCheckBox.Checked = True
            End If
        End If
    Next
End Sub
cgeier 187 Junior Poster

explorer.exe is not internet explorer. What are you trying to accomplish?

cgeier 187 Junior Poster

Have you considered using bookmarks?

Word Object Model Overview

This might also be of use:

How to: Programmatically Set Search Options in Word

cgeier 187 Junior Poster

Your first issue is being able to clearly describe the problem that you are trying to solve (the reason for creating the program or the immediate issue you are trying to solve). "we must take the inputs of both list..." What "list"?

You either need to narrow down the problem you are asking for help with, or give more details about the entire problem (program) so we can try to figure out what you are trying to do.

If you aren't able to clearly describe the problem you will never be able to solve it. Also, no one else will be able to help you.

If you know how to create your own forms, why are you using "InputBox" for input? Create a form with appropriate controls (textbox, combobox, richtextbox, etc...) to get the data from the user.

cgeier 187 Junior Poster

Where is the definition for AMSCONN?

Using statement:

You can instantiate the resource object and then pass the variable to the using statement, but this is not a best practice. In this case, the object remains in scope after control leaves the using block even though it will probably no longer have access to its unmanaged resources. In other words, it will no longer be fully initialized. If you try to use the object outside the using block, you risk causing an exception to be thrown. For this reason, it is generally better to instantiate the object in the using statement and limit its scope to the using block.

GagaCode commented: that really helped a lot thank you so much +0
cgeier 187 Junior Poster

Also note, that for testing I made most of the data types "String". You can change them as appropriate (Decimal, Date, etc).

cgeier 187 Junior Poster

If you look at the xml file, you will see that "nomina:Percepcion" occurs multiple times. So, we can use a list for it. You may be able to use an array, but I had difficulty in getting the array to work, so I switched to a list:

    <XmlElementAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property Percepcion As New List(Of ComprobanteComplementoNominaPercepcionesPercepcion)

The class is defined as follows:

Imports System.Xml.Serialization
Imports System.Xml.Schema

<XmlRootAttribute(elementName:="Percepciones", Namespace:="http://www.sat.gob.mx/nomina", IsNullable:=False)>
Public Class ComprobanteComplementoNominaPercepciones

    Public Sub New()

        'add namespace
        'xmlns = New XmlSerializerNamespaces()
        'xmlns.Add("nomina", "http://www.sat.gob.mx/nomina")
    End Sub

    'namespaces
    <System.Xml.Serialization.XmlNamespaceDeclarations()>
    Public Property xmlns As XmlSerializerNamespaces

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property TotalExento As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property TotalGravado As String

    <XmlElementAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property Percepcion As New List(Of ComprobanteComplementoNominaPercepcionesPercepcion)

    '<XmlElementAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    'Public Property Percepcion() As New ComprobanteComplementoNominaPercepcionesPercepcion

End Class

And the class referenced by "Percepcion":

Imports System.Xml.Serialization
Imports System.Xml.Schema

<XmlRootAttribute(elementName:="Percepcion", Namespace:="http://www.sat.gob.mx/nomina", IsNullable:=False)>
Public Class ComprobanteComplementoNominaPercepcionesPercepcion

    Public Sub New()

    End Sub

    Public Sub New(ByVal Clave As String, ByVal Concepto As String, ByVal ImporteExento As String, ByVal ImporteGravado As String, ByVal TipoPercepcion As String)

        Me.Clave = Clave
        Me.Concepto = Concepto
        Me.ImporteExento = ImporteExento
        Me.ImporteGravado = ImporteGravado
        Me.TipoPercepcion = TipoPercepcion
    End Sub


    'namespaces
    <System.Xml.Serialization.XmlNamespaceDeclarations()>
    Public Property xmlns As XmlSerializerNamespaces

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property Clave As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property Concepto As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property ImporteExento As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property ImporteGravado As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property TipoPercepcion As String
End …
cgeier 187 Junior Poster

TimbreFiscalDigital:

Imports System.Xml.Serialization
Imports System.Xml.Schema

<XmlRootAttribute(elementName:="TimbreFiscalDigital", Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital", IsNullable:=False), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=True, [Namespace]:="http://www.sat.gob.mx/TimbreFiscalDigital")>
Public Class ComprobanteComplementoTimbreFiscalDigital
    Public Sub New()

        'add tfd namespace
        xmlns = New XmlSerializerNamespaces()
        xmlns.Add("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")

    End Sub

    'schemaLocation
    <XmlAttribute(Namespace:=System.Xml.Schema.XmlSchema.InstanceNamespace)>
    Public Property schemaLocation As String = "http://www.sat.gob.mx/TimbreFiscalDigital http://www.sat.gob.mx/TimbreFiscalDigital/TimbreFiscalDigital.xsd"

    'namespaces
    <System.Xml.Serialization.XmlNamespaceDeclarations()>
    Public Property xmlns As XmlSerializerNamespaces

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital")>
    Public Property FechaTimbrado As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital")>
    Public Property noCertificadoSAT As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital")>
    Public Property selloCFD As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital")>
    Public Property selloSAT As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital")>
    Public Property UUID As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital")>
    Public Property version As String
End Class

Notice that "TimbreFiscalDigital" uses a new "schemaLocation", so we include it in the class definition. Also, notice that the namespaces are referred to by their URI (http://...) when using "Namespace:=". This is defined using:

Public Sub New()
    xmlns.Add("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")
End Sub

'namespaces
<System.Xml.Serialization.XmlNamespaceDeclarations()>
Public Property xmlns As XmlSerializerNamespaces

Also, the namespace is listed in "schemaLocation":

'schemaLocation
<XmlAttribute(Namespace:=System.Xml.Schema.XmlSchema.InstanceNamespace)>
Public Property schemaLocation As String = "http://www.sat.gob.mx/TimbreFiscalDigital http://www.sat.gob.mx/TimbreFiscalDigital/TimbreFiscalDigital.xsd"
cgeier 187 Junior Poster

I don't have a lot of time so I will give a brief description. The code I previously provided can be used for both serialization and de-serialization.

Some of the information I provide you may already know, but I will provide it for people who may not know. I've only learned about serialization in the past few days, so I will provide information base on what I have learned.

Add the following to the top of the classes that we are using:

using System.Xml.Serialization
using System.Xml.Schema

Create a class for the root element and then for each element that contains a sub-element.

Let's identify the structure of the XML file:

Root element: cfdi:Comprobante contains schemaLocation and multiple xmlns

Child Elements:

-cfdi:Complemento (Element)
    -nomina:Nomina (Element)
        -Departamento (Attribute)
        -NumEmpleado (Attribute)
        -    ...
        -nomina:Percepciones (Element)
            -TotalExento (Attribute)
            -TotalGravado (Attribute)
            -nomina:Percepcion (Element)
                -Clave (Attribute)
                -Concepto (Attribute)
                -ImporteExento (Attribute)
                -ImporteGravado (Attribute)
                -TipoPercepcion (Attribute)

    -tfd:TimbreFiscalDigital (Element) contains schemaLocation and xmlns
        -FechaTimbrado (Attribute)
        -UUID (Attribute)
        -noCertificadoSAT (Attribute)
        -selloCFD (Attribute)
        -selloSAT (Attribute)
        -version (Attribute)

*Note: During serialization/de-serialization the name of the object (class name, property name, variable name) will be used as the name of the XML object (element name, attribute name, etc...) unless otherwise specified. You can change that behavior by using "elementName:=".

Example 1:

<XmlRootAttribute(elementName:="Comprobante", Namespace:="http://www.sat.gob.mx/cfd/3", IsNullable:=False)>
Public Class Comprobante

End Class

Example 2:

<XmlElementAttribute(elementName:="Nomina", Namespace:="http://www.sat.gob.mx/nomina")>
Public Property Nomina As New ComprobanteComplementoNomina

To add schemaLocation, we use the following:

'schemaLocation
<XmlAttribute(Namespace:=System.Xml.Schema.XmlSchema.InstanceNamespace)>
Public Property …
cgeier 187 Junior Poster

The attached file contains a version using serialization (XmlSerializer). It doesn't de-serialize the complete file (I didn't have enough time to complete it), but it will de-serialize the information that you mentioned above. When I have more time, I will post an explanation here.

Usage:
deserializeFromXml()

Note: deserializeFromXml is defined in Module1.vb

cgeier 187 Junior Poster

Something like the following would work:

    'keeps track of selected rows
    Private selectedRowsDict As New Dictionary(Of Integer, String)

DataGridView MouseClick event:

    Private Sub DataGridView1_MouseClick(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseClick
        'allows for row de-selection by toggling
        'between row being selected and de-selected
        If selectedRowsDict.ContainsKey(DataGridView1.CurrentRow.Index) Then
            'deselect row
            selectedRowsDict.Remove(DataGridView1.CurrentRow.Index)
        Else
            'select row
            selectedRowsDict.Add(DataGridView1.CurrentRow.Index, "Selected")
        End If

        'loop through all rows in DataGridView
        'de-select rows that have been de-selected
        'select rows that have been selected
        For rowNum As Integer = 0 To DataGridView1.RowCount - 1
            If selectedRowsDict.ContainsKey(rowNum) Then
                DataGridView1.Rows(rowNum).Selected = True
            Else
                DataGridView1.Rows(rowNum).Selected = False
            End If
        Next
    End Sub
cgeier 187 Junior Poster

How are you identifying which row the user wants to select? ComboBox? TextBox? Mind reading?

cgeier 187 Junior Poster

This post may help.

If you want more help, please post more of your code--particularly the variable declarations.

cgeier 187 Junior Poster

One more way to do it (without using a loop), is to create a method that removes one word, and call it repeatedly. Although, I advise against this method.

    Private Function removeWord(ByVal userStr As String)
        Dim retStr As String = userStr

        'remove any leading or trailing spaces
        retStr = userStr.Trim()

        If retStr.Contains(" ") Then
            'string contains more than 1 word
            retStr = retStr.Substring(retStr.IndexOf(" ") + 1)
        Else
            'string contains only 1 word
            retStr = String.Empty
        End If

        Return retStr
    End Function

Usage:
Dim myStr As String = String.Empty

'call 2 times to remove 2 words
myStr = removeWord(myStr)
myStr = removeWord(myStr)

cgeier 187 Junior Poster

The easiest way to do it without using a loop is to use recursion. I will show you two recursive methods. The difference is the placement of the subtraction from the counter (numberOfWords = numberOfWords - 1). This determines whether you will use <= or just < in your "if" statement.

Note: The counter parameter numberOfWords must be passed using ByRef for this to work.

If we decrement after the "if" statement we do something like the following:

Version 1:

Private Function removeWords(ByVal userStr As String, ByRef numberOfWords As String)

    Dim retStr As String = String.Empty

    'if we decrement after this statement,
    'we use <= here
    If numberOfWords <= 0 Or userStr.Length = 0 Then
        Return userStr
    End If

                    ...

    'decrement counter
    numberOfWords = numberOfWords - 1

    'recursively call removeWords
    Return removeWords(retStr, numberOfWords)
End Function

removeWords function:

    Private Function removeWords(ByVal userStr As String, ByRef numberOfWords As String)
        Dim retStr As String = String.Empty

        'return the string when it is either
        'empty or the desired number of words
        'have been removed
        If numberOfWords <= 0 Or userStr.Length = 0 Then
            Return userStr
        End If

        'remove any leading or trailing spaces
        retStr = userStr.Trim()

        If retStr.Contains(" ") Then
            'string contains more than 1 word
            retStr = retStr.Substring(retStr.IndexOf(" ") + 1)
        Else
            'string contains only 1 word
            retStr = String.Empty
        End If

        'decrement counter
        numberOfWords = numberOfWords - 1

        'recursively call removeWords
        Return removeWords(retStr, numberOfWords)
    End Function

Version 2:
If we decrement before the "if" statement we …

cgeier 187 Junior Poster

This link looks like it is for your same project.

cgeier 187 Junior Poster

If you don't want to use a loop, you could use "Substring" and "IndexOf(" ").

cgeier 187 Junior Poster

How to: Manage Local Data Files in Your Project

Copy to Output Directory setting

-Copy always (default for .mdf and .mdb files):

...The database file is copied from the project directory to the bin directory every time you build your application. Every time you build your application and save changes to the data, those changes are overwritten when the original file is copied to the bin directory, replacing the copy that you just changed. You do not see the updated data the next time you run your application. Any changes made to the data file in the output folder will be overwritten the next time you run the application....

cgeier 187 Junior Poster

Lines 24-31 should be placed inside a loop. You will also need an option to exit (complete the order).

cgeier 187 Junior Poster

If you are repeating a lot of code, then there is probably a better way to write it (using a method/function).

There is a tutorial on how to pass data between two forms here:

How to pass data between two forms in C#

cgeier 187 Junior Poster

Depending on what testing software you use, your hdd may or may not test as bad and still be the problem. I would start by running "chkdsk" (checkdisk). Then download and run drive testing software from the hard drive manufacturer.

What I have found to work the best though, is Acronis True Image (by attempting to create an image--backup). It will error out if it finds bad sectors.

You didn't mention what brand hard drive you have, but here are some links for two different brands:

WD

*Note: A free version of Acronis is available on their website for use with a WD hdd.

Seagate/Maxtor

I believe that DiscWizard is a free version of Acronis for use with a Seagate/Maxtor hdd--at least it was in the past.

cgeier 187 Junior Poster

I've never used "Xml.Serialization", but the following has been tested with the XML file you provided above:

    Private Sub getEmployeeData(ByVal filename As String)
        Dim doc As New Xml.XmlDocument

        Dim numEmpleado As String = String.Empty
        Dim selloSAT As String = String.Empty
        Dim selloCFD As String = String.Empty
        Dim noCertificadoSAT As String = String.Empty
        Dim uuid As String = String.Empty
        Dim fechaTimbrado As String = String.Empty

        If Not (System.IO.File.Exists(filename)) Then
            MessageBox.Show(filename + " not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Return 'exit
        End If


        Try
            'load XML document
            doc.Load(filename)

            'set up NameSpaceManager
            Dim man As Xml.XmlNamespaceManager = New Xml.XmlNamespaceManager(doc.NameTable)

            'get the following information from the line that has
            'the following format:
            'xmlns:<prefix>=<url>

            'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            'add "xsi" to namespace
            man.AddNamespace("cfdi", "http://www.sat.gob.mx/cfd/3")

            'xmlns:nomina="http://www.sat.gob.mx/nomina"
            'add "nomina" to namespace
            man.AddNamespace("nomina", "http://www.sat.gob.mx/nomina")

            'xmlns:tfd="http://www.sat.gob.mx/TimbreFiscalDigital"
            'add "tfd" to namespace
            man.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")

            'get "nomina:Nomina" node
            Dim xmlNominaNominaNode As Xml.XmlNode
            xmlNominaNominaNode = doc.SelectSingleNode("/cfdi:Comprobante/cfdi:Complemento/nomina:Nomina", man)


            'if xmlNominaNominaNode has attributes, read them
            If Not (xmlNominaNominaNode.Attributes Is Nothing) Then
                For Each myAttrib As Xml.XmlAttribute In xmlNominaNominaNode.Attributes

                    'Console.WriteLine("     " & myAttrib.Name & ":" + myAttrib.Value)

                    If myAttrib.Name = "NumEmpleado" Then
                        numEmpleado = myAttrib.Value
                    End If
                Next
            End If


            'get "tfd:TimbreFiscalDigital" node
            Dim xmlTfdTimbreFiscalDigital As Xml.XmlNode
            xmlTfdTimbreFiscalDigital = doc.SelectSingleNode("/cfdi:Comprobante/cfdi:Complemento/tfd:TimbreFiscalDigital", man)


            'if xmlTfdTimbreFiscalDigital has attributes, read them
            If Not (xmlTfdTimbreFiscalDigital.Attributes Is Nothing) Then
                For Each myAttrib As Xml.XmlAttribute In xmlTfdTimbreFiscalDigital.Attributes

                    'Console.WriteLine("     " & myAttrib.Name & ":" + myAttrib.Value)

                    If myAttrib.Name = "selloSAT" Then
                        selloSAT = myAttrib.Value

                    ElseIf myAttrib.Name = "selloCFD" Then
                        selloCFD = myAttrib.Value

                    ElseIf myAttrib.Name …
cgeier 187 Junior Poster

Create a List as ddanbe stated. Then create a sort method that sorts the list based on the field that you want to use to sort it. The code below sorts by ConferenceDate, then ParticipantType, then by Participant.

Conference.vb

Public Class Conference
    Public Participant As String
    Public ParticipantType As String
    Public ChapterNumber As String
    Public ConferenceCode As String
    Public ConferenceDate As DateTime


    'constructor
    Public Sub New(ByVal Participant As String, _
                            ByVal ParticipantType As String, _
                            ByVal ChapterNumber As String, _
                            ByVal ConferenceCode As String, _
                            ByVal ConferenceDate As DateTime)

        Me.Participant = Participant
        Me.ParticipantType = ParticipantType
        Me.ChapterNumber = ChapterNumber
        Me.ConferenceCode = ConferenceCode
        Me.ConferenceDate = ConferenceDate

    End Sub

End Class

Declaration:

Private conferenceList As New List(Of Conference)

addTestDataToList:

    Private Sub addTestDataToList()
        conferenceList.Add(New Conference("Rose Brown", "Member", "pc", "1234", New DateTime(2014, 11, 7)))
        conferenceList.Add(New Conference("Megan Randall", "Guest", "fl", "1234", New DateTime(2014, 11, 8)))
        conferenceList.Add(New Conference("Mike Done", "Advisor", "nm", "1234", New DateTime(2014, 11, 7)))
        conferenceList.Add(New Conference("John Smith", "Member", "pc", "1234", New DateTime(2014, 11, 7)))
        conferenceList.Add(New Conference("Tom Brooks", "Member", "pc", "1234", New DateTime(2014, 11, 7)))
        conferenceList.Add(New Conference("Peter Davis", "Member", "pc", "1234", New DateTime(2014, 11, 8)))
        conferenceList.Add(New Conference("Jane Doe", "Guest", "nm", "1234", New DateTime(2014, 11, 7)))
        conferenceList.Add(New Conference("Bill Duncan", "Member", "fl", "1234", New DateTime(2014, 11, 8)))
        conferenceList.Add(New Conference("David Dolittle", "Member", "pc", "1234", New DateTime(2014, 11, 8)))
    End Sub

sort:

    Private Sub Sort(Optional ByVal nameSort As String = "firstname")

        'sorts by date, then by ParticipantType
        Dim tempConference As Conference

        'sort
        For i As Integer = 0 To conferenceList.Count - …