Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
dim str as String = "C:\Users\profile"
str = str.Substring(0, 1).ToLower & str.Substring(1)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

First of all when you take the square of 4 you get 16. I presume you meant square root. I would imagine that the algorithm used to find the square root results in 2 plus a very very small fraction which is not shown because it is so much smaller than 2. When you subtract 2 from that you are just left with the fractional part which is, at least on my computer, around -8 times 10 to the -39th power which is damn close to zero.

One of the first demonstrations I had on how computers do math was back in 1971 when it was shown that 1/3 + 1/3 + 1/3 was actually slightly less than one according to the computer.

flagstar commented: nice... even I have to read several times to understand completely... +7
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Let's say you have a listview named lvwStuff and it has three columns (indexed 0, 1 and 2). The following code adds one line to the listview (I have it in Details view)

Dim item As New ListViewItem
item.Text = "stuff"                 'gets added as lvwStuff.Items(0).SubItems(0)
item.SubItems.Add("stuff col 1")    'gets added as lvwStuff.Items(0).SubItems(1)
item.SubItems.Add("stuff col 2")    'gets added as lvwStuff.Items(0).SubItems(2)
lvwStuff.Items.Add(item)

Hope that helps.

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

I suppose we should have asked before posting the code whether or not this game was for a school assignment in which case, hints or code fragments would have been more appropriate. Having said that I'll post one more (complete) version. If this was for an assignment then the damage is already done. If not then perhaps the following code will illustrate some simple techniques. In any case, I was really really bored today so I had to tinker with it.

The only control you have to add via the IDE is the label (lblPlayer) at the top of the form.

Public Class Form1

    Dim buttons(2, 2) As System.Windows.Forms.Button    '3x3 array of tic-tac-toe tiles 
    Dim PlayerOne As Boolean = True                     'True=Player 1, False=Player 2  

    Public Sub New()

        'This call is required by the designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call.

        'create 3x3 array of tic-tac-toe tiles - tiles are 45x45 and range in position  
        'from 10,10 (upper left) to 110,110 (lower right). The advantage of creating the
        'controls at run time is you can access the tiles in an array and use the same  
        'handler for all tiles. The disadvantage is you have to calculate the position  
        'of all the tiles yourself.                                                     

        For row As Integer = 0 To 2
            For col As Integer = 0 To 2

                Dim x As Integer = 15 + 55 * row    'new tile x coordinate              
                Dim y As Integer = 50 + 55 * col    'new tile y coordinate …
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Another version:

Public Class Form1

    Dim buttons(2, 2) As System.Windows.Forms.Button
    Dim PlayerOne As Boolean = True

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        Dim button As System.Windows.Forms.Button
        Dim x, y As Integer

        For r As Integer = 0 To 2
            For c As Integer = 0 To 2
                x = 10 + 50 * r
                y = 10 + 50 * c
                button = New System.Windows.Forms.Button
                button.Size = New System.Drawing.Size(45, 45)
                button.Location = New System.Drawing.Point(x, y)
                button.Font = New System.Drawing.Font("MS Sans Serif", 20)
                AddHandler button.Click, AddressOf ButtonClicked
                buttons(r, c) = button
                Me.Controls.Add(button)
            Next
        Next

        ResetGame()

    End Sub

    Private Sub ResetGame()

        For r As Integer = 0 To 2
            For c As Integer = 0 To 2
                buttons(r, c).Text = ""
                buttons(r, c).Enabled = True
            Next
        Next

        PlayerOne = True

    End Sub

    Private Sub ButtonClicked(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim button As System.Windows.Forms.Button = sender

        button.Text = IIf(PlayerOne, "X", "O")
        button.Enabled = False
        PlayerOne = Not PlayerOne
        CheckForWin()

    End Sub

    Private Sub CheckForWin()

        Dim r, c As Integer

        'check for three across

        For r = 0 To 2
            If buttons(r, 0).Text <> "" And buttons(r, 0).Text = buttons(r, 1).Text And buttons(r, 0).Text = buttons(r, 2).Text Then
                MsgBox("win for " & buttons(r, 0).Text)
                ResetGame()
                Exit Sub
            End If
        Next

        'check for three down

        For c = 0 To 2
            If buttons(0, c).Text <> "" And buttons(0, c).Text = buttons(1, c).Text And buttons(0, c).Text = buttons(2, …
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The solution above will correct the issue but it would just stop the error reporting issue, not the real problem inside your computer.

I believe your point was that the issue should be corrected rather than masked. I agreed with you. That's why I was curious as to which approach shredder took to resolve the problem.

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

Care to share your solution?

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

I presumed the problem was not that an error kept repeating because that message is only supposed to display once after a reboot. A problem that causes the generation of that type of message would take down the entire system so it doesn't appear that the problem is recurring, just that the message keeps popping up.

Do you know how to check the event logs? The quick way is to run EVENTVWR.MSC. Perhaps this will indicate the source of the error message.

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

The first thing I would suggest is to create a two-dimensional array for the buttons. If you want to place the buttons manually (at design time) you can initialize the array at run time as follows (in the form New or Load event handlers). Just make sure you declare the array to have Class scope.

Dim buttons(2, 2) As System.Windows.Forms.Button 'make this Class scope

buttons(0,0) = boxButton1
buttons(0,1) = boxButton2
buttons(0,2) = boxButton3
buttons(1,0) = boxButton4
buttons(1,1) = boxButton5
buttons(1,2) = boxButton6
buttons(2,0) = boxButton7
buttons(2,1) = boxButton8
buttons(2,2) = boxButton9

Or if you like you can declare the array as (3,3) and use indices 1-3 instead of 0-2 if that seems more natural. Using the array you can use loops for your testing instead of hard coding nine separate tests.

It is slightly more complicated to do the following but you could also create the buttons at run time. This is cleaner and allows you to have only one routine that handles the click event for all buttons. That would allow you to code the handler as:

Private Sub ButtonClicked(ByVal sender As Object, ByVal e As System.EventArgs)

    Dim button As System.Windows.Forms.Button = sender

    If button.Text = "" Then
        button.Text = IIF(PlayerOne,"X","O")
        CheckForWinner()
    End If

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

See if this helps:

Right click "My Computer" and choose "Properties" from the context menu.
Go to the "Advanced" tab
Click the "Error Reporting" button near the bottom right
Select "Disable Error Reporting"

I don't know why the message keeps popping up but this may disable it.

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

Or you can create a file with that extension, then from an Explorer window, right click on that file and choose "Open With". From there you can select your custom program and select "Always open with this program".

You can also do this from Control Panel -> Default Programs

Either way is safer than modifying the Registry directly

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

You might find it easier to do this with AutoIt using either vbScript to interface to the AutoItX control or the builtin AutoIt scripting feature. You can get more information at

http://www.autoitscript.com/site/autoit/

It's free, by the way.

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

From "Sybex - Mastering Microsoft Visual Basic 2008":

Another benefit of using streams is that you can combine them. The typical example is that of encrypting and decrypting data. Data is encrypted through a special type of Stream, the CryptoStream. You write plain data to the CryptoStream, and they’re encrypted by the stream itself. In other words, the CryptoStream object accepts plain data and emits encrypted data. You can connect the CryptoStream object to another Stream object that represents a file andwrite the encrypted data directly to the file. Your code uses simple statements to write data to the CryptoStream object,
which encrypts the data and then passes it to another stream that writes the encrypted data to a file.

I haven't tried this but it may point you in the right direction of a more secure encryption.

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

How about moving your CSV file into another folder and changing strfilename to the fully qualified file name like "d:\temp\test.csv"

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

To send a message to another user on the network you could try the "net send" command although I do not know if this available in your version of Windows.

royng commented: offset negative rep +5
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Copy the following code into a file named msgbox.vbs. Display a message from the
command prompt by:

C:\> msgbox "my message"
C:\> msgbox "my message" "my title"

If you want multiple lines then include \n as in

C:\> msgbox "this\nhas\nfour\nlines" "My Message Box"

set arg = Wscript.Arguments

select case arg.Count
    case 0
        Wscript.Echo ""
        Wscript.Echo "Display a message box with the given text and (optional) title"
        Wscript.Echo "\n in text will skip to a new line"
        Wscript.Echo ""
        Wscript.Echo "Usage:"
        Wscript.Echo ""
        Wscript.Echo "    msgbox text [title]"
        Wscript.Echo ""
        Wscript.Quit
    case 1
        prompt = arg(0)
        title  = "Message Box"
    case 2
        prompt = arg(0)
        title  = arg(1)
end select

prompt = Replace(prompt,"\n",vbCrLf)

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

There is an excellent series of pages on hard disk troubleshooting at

http://www.pcguide.com/ts/x/comp/hdd/errors.htm

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

For more technical information and warnings, etc go to

http://www.pcguide.com/ref/hdd/geom/formatLow-c.html

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

Sorry. I exceeded my length limit. Here is the rest...

As long as nobody parks "over top" of an existing vehicle, that vehicle can be recovered. Likewise with a quick format. Your files are still physically on the drive and, with special tools, can be recovered.

If the attendant is feeling especially malicious he may decide to not only clear the board but also physically have all of the vehicles towed and shredded for scrap. Naturally this takes longer than just clearing the board. You will notice the same if, when you format your drive you do not check the quick-format option. Instead of just rewriting the file allocation table, the format process must rewrite each sector on the drive.

Now we get to the biggie. Suppose the owner of the parking lot has decided that the lot has just too many cracks and potholes. At that point he decides to close the lot for an extended period and send in the construction crew to rip up the lot, repave it and repaint all of the lines. This is a low-level format. Low-level formatting recreates the positions of the tracks and sectors on the drive and rewrites the control structures defining where the tracks and sectors are. Repaving the lot takes special tools. Likewise for doing a low-level format of your hard drive.

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

Forgive me if some of this is too basic. I just copied it from an explanation I gave to a neighbour/friend who was unclear on the concepts as explained in highly technical (and highly inappropriate for the audience) terms to the computers for noobs evening education class.

Imagine an empty, paved parking lot with the lines painted on. There is a gate at the entrance and the parking lot attendant has a board where he keeps track of what spots are filled. At the moment the board is empty. This is equivalent to a freshly formatted hard drive. As you save stuff to disk (park cars), the attendant keeps track of which parking spots are taken. The board is equivalent to the file allocation table.

At the start, the attendant assigns parking spots in sequence so all of the cars occupy one area of the lot but as people come and go blank spots appear in the lot (your hard drive becomes fragmented). If a large semi-trailer or Winnebago shows up early enough it may be assigned several adjacent parking spots, however, if it shows up late enough in the day there may not be enough adjacent spots to be able to park. The attendant has two choices. He can refuse to park the vehicle or he can reshuffle all of the existing cars so that they occupy the lower numbered spots. This is a time-consuming operation, especially if he waits until the lot is badly fragmented. Doing …

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

I really have to start proof-reading my postings.

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

Please not that on the site I referred you to they state that a low level format is the last step to try so I suppose I should have recommended

1) try non-quick format
2) try low-level format

in order to make the preferred choices more clear. Good luck.

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

How about copying all of the files from the suspect disk to some other storage media then doing a low level format of the suspect disk. Normally the low level format is only done once at the factory but you may be able to get a utility for this from the manufacturer. You can start by looking here:

http://www.ariolic.com/activesmart/low-level-format.html

If you aren't ready to try that just yet then do a regular (ie non-quick) format via Windows, then do a chkdsk to see if it reports any errors.

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

Hitachi has a free drive fitness test that you can burn to a CD and boot from. It is non-destructive so you can run it against your hard drive and not worry about overwriting your files. Download and docs are at

http://www.hitachigst.com/support/downloads/#DFT

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

Have you tried sfc /scannow

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

When you check your services (run by services.msc) what is the status of the "Plug and Play" service?

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

I had the same problem with my Dell. There was a (default) hotkey combo set when I installed Windows 7. I disabled it by going to

Control Panel -> Region and Language -> Keyboards and Languages

click on Change Keyboards...

select the Advanced Key Settings tab

You can set or disable the hotkeys here.

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

What happens when you go into the device manager (you can run it directly by entering devmgmt.msc in the run menu). Do you have any items with yellow flags? Does anything change when you do "Action -> Scan for Hardware Changes"? Are any of the new devices listed under any of the device categories?

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

If you want to block specific sites you can edit the file

c:\windows\system32\drivers\etc\hosts

for each site that you want to block, add a line like the following

127.0.0.1 site-address

for example, if you wanted to block access to the site www.wired.com you would add

127.0.0.1 www.wired.com

Normally, if you entered http://www.wired.com into your browser address bar, a DNS (domain name server) would convert that address to an IP address (in this case, 216.246.75.107). What the new entry in HOSTS does is force the location to the address you specified (127.0.0.1) which, instead of being the actual site is now your localhost adapter.

Note - you will have to run your editor as Administrator. Also, once you are done, you can check the results by opening a command window and typing (substitute your blocked website address)

ping www.wired.com

you should see

Pinging www.wired.com [127.0.0.1] with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time=1ms TTL=128

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

Do you have any programming experience?

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

The way I would do it is to create a vbscript file that creates a Microsoft Word object and uses that in a loop to open each file in the folder and check the text. If you are not familiar with scripting or creating scripted controls then it becomes very difficult. I had to create many such scripts to tie processes together before I retired.

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

I'll just ask two questions then. How much is your data worth? How much is your time worth?

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

Just as a note (now that all the real work is done), I always enable /sos in the boot.ini. This causes Windows to display drivers as they are loaded (like you see in safe mode). I always prefer to see this instead of the no info "idiot lights". If it hangs anywhere while loading drivers you will see where the problem lies.

You can set this on one of the tabs under msconfig.exe or you can edit boot.ini directly. On my old XP system this changed

multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect

to

multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect /sos

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

Pick up a copy of SpinRite (I keep recommending this software but I do not get anything for my recommendation) and create bootable media (usb stick or CD) then boot off this media. Run diagnostics on the hard drive and see what it reports. hard drive controllers have error correction built in. All hard drives get errors but almost all can be corrected. That is what the controller does. SpinRite disables (temporarily) this correction so you can see exactly how your drive is performing. I always recommend running it on a new drive to get a baseline to compare to later performance. In some cases SpinRite can map out bad sectors and even recover data from those bad sectors.

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

The following function will return true if the given file is <= numsecs old. Just convert 3 hours to seconds and pass as an argument.

import os
import time

def newFile(file,numsecs):
	if time.time() - os.path.getctime(file) <= numsecs:
		return True
	else:
		return False