Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

For every keystroke. Add this event handler and you will see. The titlebar will be updated every time you press a key.

Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
    Me.Text = TextBox1.Text
End Sub
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Let's say you have a group of 147 people and 36 are female. That means that the fraction of people who are female is 36/147. The percentage of females is one hundred times that. So

Dim people As Integer = 147
Dim female As Integer = 36

Dim percent As Double = 100.0 * female / people

'format as floating point with two decimal places

MsgBox(percent.ToString("F2") & "%")
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

A percentage of what? Are you having problems with the calculation or with the conversion (formatting) for display?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Except that my parameter names match the names the OP used in lines 7 and 8. If they don't match then it doesn't work.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Try setting the command to this string first

cmd.CommandText = "Update HallTransaction Set status=@statu where ID=@custid"

and don't forget to put single quotes around text fields.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

How elaborate do you want to get. A very simple solution is Stickies. This is a replacement for the Windows sticky-notes app. It supports alarms (you can put a sticky to sleep, visibly or invisibly) and have it alarm on a given date/time. Or you can leave a to-do sticky on your desktop (you can collapse it into the title bar or leave it open). It's also free. I've been using it for years.

If you have Microsoft Office, Outlook has a very good calendar with task lists, to-do lists, reminders, etc. If you use ThunderBird for email then there is a calendar plugin that works well (so I've been told).

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can simplify the loops by using

For Each phCheck As CheckBox In Me.Controls.OfType(Of CheckBox)()

That will iterate through only CheckBox controls.

iFrolox commented: Thanks for trying :) it have me same result as my code :P +2
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

@Pride

What I said has nothing to do with saving. It doesn't matter if lines() is saved en masse to the file or a line at a time. All that Filter does is return an array of strings that either contain or do not contain the given string. If the intention was to read or save the lines one at a time then the array would not be necessary. The lines could be read into or save directly from the ListBox control.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If lines() is the original array of lines from the text file (that you have copied to the textbox for display), you can remove a particular line (or lines) from the array by using the Filter function

dim newlines() as String = Filter(lines,"some string",include)

If include=True then Filtere will return all of the lines that contain the string. If include=False then all lines NOT containing the string will be returned. The easiest way to maintain the list is to apply filter every time an item is removed from the listbox as in

lines = Filter(lines,removedText,False)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Wasn't this already asked and answered here?

Begginnerdev commented: Good catch, Iggy. +5
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You'll have to read all of the lines into an array, modify the requested line, then write the array back out to the file. All you are doing is modifying the line in memory.

Dim lines() as String = IO.File.ReadAllLines(MYFILE)

For i As Integer = 0 to Ubound(lines)
    If lines(i).Contains(...
        lines(i) = 'new value of line
        Exit For
    End If
Next

IO.File.WriteAllLines(MYFILE,lines)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

As in

Try
    num = CInt(InputBox("Enter Integer"))
    If num > max Then max = num
    If num < min Then min = num
    x += 1
Catch ex As Exception
    MsgBox("oops")
End Try

And by the way, x is almost never a good choice for a descriptive variable name.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can start by setting the values of min and max outside the loop as follows

Dim min As Integer = Integer.MaxValue
Dim max As Integer = Integer.MinValue

InputBox returns a string so you can't assign it directly to a numeric variable. You have to convert it. However, just because a string is numeric that doesn't mean it can be safely converted and assigned. For example, the string "999999999999999999999" is numeric but you can't convert it to a 32 bit integer. So you'll still need the Try-Catch. You want to minimize the code in the structure so put it inside the loop.

Try
    num = CInt(InputBox("Enter Integer"))
    'update max and min here
Catch ex As Exception
    MsgBox("oops")
End Try
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Your original post was ambiguous. You said you had a tab delimited file which means one complete record per line with the individual fields separated by a tab character. The form you gave an example of is not tab delimited. I based my answer on option one because I am a programmer and therefore lazy. If your data is in the second form then you sorta do it the same way. If the file contains only one set of data then you can use the following (which will work no matter what order the data is in)

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Dim record As New Dictionary(Of String, String)

        For Each line As String In System.IO.File.ReadAllLines("d:\temp\test.txt")
            Dim fields() As String = line.Split(":")
            record.Add(Trim(fields(0)), Trim(fields(1)))
        Next

        TextBox1.Text = record("Forename")
        TextBox2.Text = record("Surname")
        TextBox3.Text = record("Employee Number")

    End Sub

End Class

If you have multiple employees in the file then you can create nested dictionaries where the outer dictionary is a

Dim Employees As New Dictionary(Of String, Dictionary(Of String,String))

The key would be something unique such as the Employee Number.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
For Each line As String In System.IO.File.ReadAllLines("myfile.txt")
    Dim fields() As String = line.Split(vbTab)
Next

After the Split, fields will contain all of the fields in the input line, one field per entry. Forename, Surname and EmployeeNumber are fields(1, 3 and 5) respectively.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

In SQL, to select the largest value from a set of values you use the MAX function as in

select MAX(citation) from myTable
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you want to get the second to last entry you could do

mydata.MoveLast()
mydata.MovePrevious()

Assuming you have at least two records, mydata.BOF will be false and you will be pointing at the second to last record.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

To get a particular slot you can use the Keys collection. mylist.Keys(3) gets the key in the fourth (zero-relative) position and the value at that position is mylist(mylist.Keys(3)). If you want to sort on different fields then you will have to do it via code. Unless you want to get a little fancier. If so you can create what is called a detached recordset. The following code shows you how to do that. Along with the "Imports ADODB" line, you will also have to add a reference to adodb. To do that, go to the Project menu and select "Add Reference". You will find adodb under the .NET tab (you may have to sort on component name first).

Imports ADODB

Public Class Form1

    Private mydata As ADODB.Recordset

    Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        mydata.Close()
    End Sub

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        'Create a recordset object. Cursors can be server side or client side.
        'Because the recordset will not connect to a source (it is detached) we
        'have to specify a client side cursor (and no active connection).

        mydata = New ADODB.Recordset
        mydata.CursorLocation = CursorLocationEnum.adUseClient
        mydata.LockType = LockTypeEnum.adLockBatchOptimistic
        mydata.CursorType = CursorTypeEnum.adOpenStatic
        mydata.ActiveConnection = Nothing

        'Add one field for each field of data in the text file

        mydata.Fields.Append("fld1", DataTypeEnum.adDate)
        mydata.Fields.Append("fld2", DataTypeEnum.adInteger)

        mydata.Open()

        Dim first As Boolean = True

        For Each line As String In System.IO.File.ReadAllLines("d:\temp\test.txt")

            'split the input line inito two fields at the comma separator

            Dim flds() As String = line.Split(",") …
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Yes.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Use & instead of + to concatenate strings

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

@TnTinMN - I think you are overcomplicating things. Also, I don't see any floating point values so loss of accuracy isn't a concern.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

All you have to do is add a flag so that the first line gets special processing.

        Dim mylist As New SortedList(Of Date, String)
        Dim firstLine As Boolean = True

        For Each line As String In System.IO.File.ReadAllLines("d:\temp\test.txt")
            Dim flds() As String = line.Split(",")
            If firstLine Then
                Label1.Text = line
                firstLine = False
            Else
                mylist.Add(CDate(flds(0)), flds(1))
            End If
        Next

        For Each key As Date In mylist.Keys
            TextBox1.AppendText(key.ToString("dd/MM/yyyy") & vbTab & mylist(key) & vbCrLf)
        Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

My.Application.CommandLineArgs

returns an array of strings, one string per argument

Pride commented: Good +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You just have to change the name of the server in the connection string. You may have to get the DBAdmin to set up access rights for you.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
        Dim mylist As New SortedList(Of Date, String)

        For Each line As String In System.IO.File.ReadAllLines("d:\temp\test.txt")
            Dim flds() As String = line.Split(",")
            mylist.Add(CDate(flds(0)), flds(1))
        Next

        For Each key As Date In mylist.Keys
            TextBox1.AppendText(key.ToString("dd/MM/yyyy") & vbTab & mylist(key) & vbCrLf)
        Next

You have to reformat the date for display as shown. If you just use ToString with no arguments you will get " 00:00:00" added to the date.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'm a big fan of letting the computer do as much as it can for you. Generally, the less code I have to write, the fewer chances I have to introduce a bug. In that case:

Dim mylist As New SortedList(Of Date, String)

For Each line As String In System.IO.File.ReadAllLines("d:\temp\test.txt")
    Dim flds() As String = line.Split(",")
    mylist.Add(CDate(flds(0)), flds(1))
Next

converts the values from string to Date which can be automatically kept in sorted order by the SortedList class. Once all of the values have been read in you can copy them, in sorted order, to whatever is appropriate - textbox, database, file, etc. Note that this code depends on the system short date format being set to dd/mm/yyyy.

@TnTinMN - I am aware that reading the file in one fell swoop may not be appropriate for exceedingly large files (I can't see this really being a problem - who stores data like the above in multi-gig text files), but for the sake of illustration I think it makes the sample code clearer by focusing on the technique rather than adding exttaneous file i/o interface code.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I was on about how western people a lot convert to Islam

Got any figures to go with that claim ?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

@Rouf mir

Can anyone please tell me the purpose of life and all this drama in this universe?

No. It's up to you to determine your purpose on your own. If anyone else tries to tell you your purpose, walk away or better yet, run. As far as I am concerned, as good a personal philosophy as any has been proposed by Wil Wheaton. That philosophy is "don't be a dick".

Why was this earth created?

The universe is not concerned with "why". "Why" is a concept created by people. The universe just is. I am more interested in "how" than "why".

Why we were born?

You were born because at some point your parents had intercourse. Don't read anything more into it.

Why so much harderships in the life?

A few billion years of evolution clearly indicates that for most living things, life is not easy. Except for a privileged few, hardship is the norm.

What will happen after death? Where will we be?

Remember what it was like before you were born? Same thing.

It is not thaat 'Hani' is trying to defy his religion. It is the fact that he is sincerely trying to protect us from the fire of hell as per his religion.

I have found that the same people who tell me that my religious beliefs are wrong (in order to save my immortal soul, of course) seem to get very upset …

mike_2000_17 commented: Awesome! +0
stultuske commented: love the neutral and well thought answers, allthough I think the real "Reverend Jim Ignatowski" would have a completely different set of answers :) +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The easiest way to check is to use a regular expression. Here is an example for your particular requirements:

Imports System.Text.RegularExpressions

Public Class Form1

    Private Sub btnTest_Click(sender As System.Object, e As System.EventArgs) Handles btnTest.Click

        If Regex.IsMatch(txtTestStr.Text, "^[2-9]\d{2}-\d{3}-\d{4}$") Then
            txtResult.Text = "Match"
        Else
            txtResult.Text = "No Match"
        End If

    End Sub

The above sub compares the text in the TextBox, txtTestStr.Text, with the regular expression "^[2-9]\d{2}-\d{3}-\d{4}$" and displays the result in another text box. The regular expression can be broken down as follows

    ^       the start of the string
    [2-9]   any digit in the range 2 to 9
    \d{2}   exactly two other digits
    -       a dash
    \d{3}   exactly three digits
    -       a dash
    \d{4}   exactly four digits
    $       the end of the string

You can find many other useful patterns here

daniel955 commented: nice +1
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Oh and the Council of Nicaea in A.D. 325 did quite a bit -ha, I said bit lol- of re-writing to the bible.

An interesting book on the subject is "Misquoting Jesus: The Story Behind Who Changed the Bible and Why" by Bart D. Ehrman

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can use the second form (List). Just replace intSalaries.Length with intSalaries.Count as in

    Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click

        ' displays the salary amount associated with a code

        Dim intSalaries As New List(Of Integer)

        For Each line As String In System.IO.File.ReadAllLines("D:\temp\test.txt")
            If IsNumeric(line) Then
                intSalaries.Add(CInt(line))
            End If
        Next

        Dim strInputCode As String
        Dim intCode As Integer
        Dim intSub As Integer

        strInputCode = InputBox("Salary code (1 - 6)", "Salary")
        Integer.TryParse(strInputCode, intCode)

        ' subtract 1 from the code to get the appropriate subscript

        intSub = intCode - 1
        If intSub >= 0 AndAlso intSub < intSalaries.Count Then
            lblSalary.Text = intSalaries(intSub).ToString("C2")
        Else
            lblSalary.Text = String.Empty
            MessageBox.Show("The salary code must be from 1 through 6.",
            "Salary", MessageBoxButtons.OK,
            MessageBoxIcon.Information)
        End If

    End Sub

Except you probably don't want to read the values every time the button is clicked. You'd initialize the List once on Form Load.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'm not as concerned with him posting religion based material. In Geek's Lounge pretty much any topic is fair game. What concerns me is the posting of misleading, and in some cases, completely inaccurate material. From my reading (which includes sections from the Q'uran) Islam is not a religion of peace and tolerance. While it is true that there have been periods in history where Islam was far more tolerant of other religions than others were of Islam, at its core, Islam is fundamentally an intolerant religion. Have you ever heard of a Jewish suicide bomber? Does any other religion retain its membership by threatening to kill anyone who leaves?

Lest I be considered a rabid anti-Islamist, a thorough reading of the Old Testament shows that Christians can hardly take the moral high ground. The Old Testament is just as filled with hatred and violence as the Q'uran.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Note that this does no error checking - it assumes that all of the strings represent numbers.

        Dim strings() As String = System.IO.File.ReadAllLines("D:\temp\test.txt")
        Dim numbers(UBound(strings)) As Integer

        For i = 0 To UBound(strings)
            numbers(i) = CInt(strings(i))
        Next

A version that checks but does not strictly speaking use an array is

        Dim numbers As New List(Of Integer)

        For Each line As String In System.IO.File.ReadAllLines("D:\temp\test.txt")
            If IsNumeric(line) Then
                numbers.Add(CInt(line))
            End If
        Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I have no idea what "phBAH.phTabControl" is. Start a new (blank) project. Add a few textboxes and a few other controls at random. Don't bother setting any properties or names other than the defaults. Now replace the existing code with the following:

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        For Each ctrl As TextBox In Me.Controls.OfType(Of TextBox)()
            AddHandler ctrl.GotFocus, AddressOf TextBox_GotFocus
            AddHandler ctrl.LostFocus, AddressOf TextBox_LostFocus
            ctrl.Tag = ctrl.BackColor
        Next

    End Sub

    Private Sub TextBox_GotFocus(sender As Object, e As System.EventArgs)
        Dim txt As TextBox = sender
        txt.BackColor = Color.LightGray
    End Sub

    Private Sub TextBox_LostFocus(sender As Object, e As System.EventArgs)
        Dim txt As TextBox = sender
        txt.BackColor = txt.Tag
    End Sub

End Class

After consideration I thought it was better to have separate handlers for "got" and "lost" focus. Just my opinion. In any case, try the above code. You can even set the text boxes to have different background colours at design time. The starting colour will be restored after the control loses focus.

iFrolox commented: Works :) +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Or a little cleaner

Private Sub FocusChanged(sender As Object, e As EventArgs)

    If CType(sender, TextBox).Focused Then
        CType(sender, TextBox).BackColor = Color.FromArgb(65, 65, 65)
    Else
        CType(sender, TextBox).BackColor = Color.FromArgb(60, 60, 60)
    End If

End Sub

or

Private Sub FocusChanged(sender As Object, e As EventArgs)

    If sender.Focused Then
        sender.Tag = sender.BackColor
        sender.BackColor = Color.LightGray
    Else
        sender.BackColor = sender.Tag
    End If

End Sub    

Which saves the current background colour before setting the focused colour (useful if not all of your textboxes are the same colour). If you are a purist you can do

Private Sub FocusChanged(sender As Object, e As EventArgs)

    Dim txt As TextBox = sender

    If txt.Focused Then
        txt.Tag = txt.BackColor
        txt.BackColor = Color.LightGray
    Else
        txt.BackColor = txt.Tag
    End If

End Sub
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you want to handle all textboxes the same way you can create two generic handlers such as

    Private Sub TextBox_GotFocus(sender As Object, e As System.EventArgs)
        sender.BackColor = Color.LightGray
    End Sub

    Private Sub TextBox_LostFocus(sender As Object, e As System.EventArgs)
        sender.BackColor = Color.White
    End Sub

then on form load you can attach these handlers to every textbox as

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        For Each ctrl As TextBox In Me.Controls.OfType(Of TextBox)()
            AddHandler ctrl.GotFocus, AddressOf TextBox_GotFocus
            AddHandler ctrl.LostFocus, AddressOf TextBox_LostFocus
        Next

    End Sub
Begginnerdev commented: I laugh every time I see your picture. +5
iFrolox commented: Thats what i needed +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Or if you can't or don't want to group the controls, set the Tag property of each to some known value then test in a loop like

For Each ctrl As Control In Me.Controls
    If ctrl.Tag = "my value" Then
        ctrl.Enabled = True
    End If
Next
iFrolox commented: Thank you for providing the code +1
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

To do that you create an installer package. When a user runs the installer it copies all of the files needed to run the application to the user's computer. You can find detailed instructions here

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

When you encrypt it you are also encrypting the carriage return and line feed characters. As such, ReadAllLines can't parse the text back into separate lines. You'll have to encrypt and write each line separately to preserve the delimiters.

iFrolox commented: Exactly what i had to do, thank you for the reply. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Try

For Each Info As String In System.IO.File.ReadAllLines(AccFileR)
    Info = IDecode.decryptString(Info)
    'Debug.WriteLine(Info)
    Accounts.Add(New Account(Info.Split(CChar(","))))
    My.Forms.Main_frm.AccNumber.Items.Add(iCount)
    iCount += 1
Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The scriptable component, autoitx, uses a dll named AutoItX3.dll (or AutoItX_x64.dll).

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Have you looked at autoit. There is a component, AutoitX, that can be created and used from within vb.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I could only do so much testing here so I hope this helps.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I wrote up two skeleton apps. The first is the server that runs the folder watch and the generator. The second is the client app. Both are missing the code to load and process the Excel files (hard to do if you don't know what the processing or data are). I've also attached the zipped project files.

Server App
Imports System
Imports System.Collections

'                                                                                                   
'  Name:                                                                                            
'                                                                                                   
'    EruditioServer (catchy name, don't you think?)                                                 
'                                                                                                   
'  Description:                                                                                     
'                                                                                                   
'    This app monitors the folder given in PRODFILES and watches for rename events on xls files.    
'    It assumes that this will only ever happen when a .tmp file is renamed to .xls upon the        
'    completion of an edit by a user.                                                               
'                                                                                                   
'    When a .tmp is renamed to .xls, this app starts a background thread which takes the newly      
'    edited .xls file, opens it to create a one line summary, then updates a summary file with      
'    that summary.                                                                                  
'                                                                                                   
'  Notes:                                                                                           
'                                                                                                   
'    This code is just a skeleton. It includes no extra code to actually process the Excel files.   
'    That code is left to the implementing programmer to fill in.                                   
'                                                                                                   
'    I understand that all of the .xls files are processed automatically during the night to        
'    ensure that no summaries were missed. It should be an easy matter to add that functionality    
'    into this code by creating a timer which would scan the PRODFILES folder and add all .xls      
' …
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That simplifies things. With a little luck I'll be able to post some skeleton code for the user and control apps showing the interlock logic. This will be my first multi-threaded app under VB, but I am optimistic it will work.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Keeping all the lines in order wouldn't have any effect on the GOTO

In that case I think you can get away with

       Dim newline As Integer = 0

        For Each line As String In System.IO.File.ReadAllLines("D:\temp\jumpin.txt")

            ListBox1.Items.Add(line)

            Dim linenumb As String 'the N#### portion of the line
            Dim linecode As String 'everything other than N####

            If line.StartsWith("N") Then
                newline += 10
                linenumb = Split(line)(0).Substring(1)
                linecode = line.Substring(Len(linenumb) + 1)
                line = "N" & newline.ToString("0000") & linecode
            End If

            ListBox2.Items.Add(line)

        Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

We had a similar situation where we had a client computer set up to continuously run a river flow optimization program. It was pretty CPU intensive so we decided it would be better to not have it running on the server.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The text files are edited, rather than recreated.

I'm confused. Do the users edit the text files or the Excel files?

It occurred to me as I was coding up a shell example that because you are rendering many Excel files down into a few text files, you are likely going to have to process all of the Excel files every time any Excel file is modified. This might not be the case, but because I do not know the nature of the files I can't really make an assumption either way. Depending on the situation this may simplify the processing. If you have to process all of the Excel files then it is not necessary to know which file has changed, only that a change has been made.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Before I retired I always found it useful, when I got a request, to rewrite the request in my own words and send it back to the person making the request with the question, "is this what you are asking for?". I found that in most cases what I thought the user wanted was not in sync with what the user said he wanted. So let me restate the problem to make sure we are in agreement.

  • You have hundreds of Excel files in a shared folder.

  • These files can be edited by multiple users.

  • The information in these files is used to generate a smaller number of text files.

  • When an Excel file changes, the text files must be recreated

You can't have more than one file watcher active at a time. If the file watcher was part of the user app then every time any user save his changes, ALL copies of the file watcher would trigger the same event. Therefore you must have only one file watcher running and logically it should be on the server.

Also, a server is generally much more powerful than any client PC. Because the files are stored on the server there is no network latency when processing the files. Therefore it should take much less time to generate the text files on the server than on a client. It is also less likely that the server will be interrupted while processing. Client machines can be subject to power outages and …

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Another thought on the server process. You could bundle the FileSystemWatcher and the generation process in one app and just make the generator a separate thread. They could share a common structure which would be a list of files that were renamed. As long as you also share a variable that can be used as a lock so that both threads can not update the list at the same time everything should be fine. I've never programmed a multi-threaded app in vb but the basics seem pretty, well, basic. It would be easier for two threads in one task to communicate than for two separate tasks.