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

A couple of door-bottom weather strips (one for your door and one for the neighbour's) might do a lot to cutting down the amount of smoke. The cost is minimal and if the neighbour or landlord won't spring for it you might want to spring for them yourself. They install easily.

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

I can't test this out because I don't have anything older than vb.net 2010 but I don't believe you need the Set keyword. Try just

dbgridvar = Form1.Datagrid1

Are you getting an error message?

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

You don't need Using.

Dim text As String = My.Computer.FileSystem.ReadAllText(RestranName)

will read the entire file into one string variable.

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

You can effectively run the same code in vb.net with minor modifications. Normally I would try the code before posting but my regular laptop is toast and I m using n old clunker (without vb.net instlled nd with a flkey "A" key). Essentially, wht you would do is read the text in by

My.Computer.FileSystem.ReadAllText(filename)

then use the Replace function as previously noted. I'd be more specific but I hve no way to write/test the code at the moment.

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

We have 150 different properties in our group. As part of each hotels night audit, they generate this text file that is stored in the hotels specific folder. It's all on one server, but in their individual folder. This part of the reason I would have preferred to have written the code in VB.net as I had started a program that do the conversion after pushing a button on the users desktop.

It might have been a good idea to have stated that at the very start. Your original request was that you wanted to convert "a" text file. A great many projects have been derailed because the user requirements were not properly specified up front.

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

And, for the record, when running a script from the command line, the output command is not msgbox. You should use wscript.echo as in

wscript.echo "Hello, world"

That will write the output to the console window. Msgbox, on the other hand, pops up a message box and waits for you to close it. If you have a lot of output you will get very tired of closing message boxes.

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

Does this mean that a copy of this program will need to be in every folder where the text file exists?

No. Just put convert.vbs in a folder that is in your %PATH%. If you don't know how to do that then after opening a command shell just do

set %PATH%=%PATH%;myfolder

where myfolder is the name of the folder containing convert.vbs. If you don't want to do that then just run it by

D:\myfolder\convert infile outfile

I don't see anything in your code that will direct it to where the original file will be found or where the new, "Save As" file will go. I've got to believe there are some lines of code that need to be inserted to tell it what to do.

The script is complete and does not require any Sub Main or other code. As I stated, the script is run from the command prompt, not by double clicking an icon. The format is

convert inputfile outputfile

The input and output files are specified on the command line.

If the files are in the current folder then just specify the file name as in

convert infile.txt outfile.text

You can qualify the file name(s) with a path if necessary. If you want to convert a lot of files then you can create a Windows batch (.cmd) file containing

convert ifile1.txt ofile1.txt
convert ifile2.txt ofile2.txt
convert ifile3.txt ofile3.txt
etc.

There's no need to complicate this.

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

From Windows, run DISKMGMT.MSC. That will show you the disks and partitions. Take a snapshot of the window (ALT-PRTSCR) and post it here. The bottom pane of disk manager will be the most useful so size it so all disks are shown.

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

Just to clarify, this isn't a vb or vb.net program. It is a stand alone vbscript (like a super batch file). Just copy and paste the code into notepad and save it as convert.vbs. You run it from the command line (what you might call a DOS shell).

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

You can reference controls dynamically by name by using

Me.Controls(name)

So you could do something like

Dim data() As String = {"box1", "box2", "box3"}

For i = 0 To 2
    Me.Controls("textBox" & (i + 1)).Text = data(i)
Next

If you name your controls tbxProp0, tbxProp1, tbxProp2 then you can do

Dim data() As String = {"box1", "box2", "box3"}

For i = 0 To 2
    Me.Controls("tbxProp" & i).Text = data(i)
Next

Not exactly like your code (I'm not doing any input) but you should get the idea.

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

My program doesn't require Excel. Let's clear one thing up first. Is your input file a text file or is it a PDF file? As for the script, I thouught it was simple enough to not require comments.

'vbscript uses helper objects. fso is a FileSystem object that has methods to
'perform file type functions. Wscript.Arguments allows access to command line
'arguments. This script requires two parameters, an input file and an output 
'file. If you don't enter two parameters you get some brief help and the
'script exits.

set fso = CreateObject("Scripting.FileSystemObject")
set arg = Wscript.Arguments

if arg.Count <> 2 Then
    Wscript.Echo "Convert inputfile outputfile"
    Wscript.Echo "Creates outputfile from iniputfile by replacing"
    Wscript.Echo "unix line-ending (vblf)) to Windows format (vbcrlf)"
    Wscript.Quit
End If

'ReadAll reads the entire file into a string variable. The first Replace
'converts a linefeed character into a linefeed and carriage return. If the
'input file was already in Windows format (CRLF) then the first Replace
'would have changed it to CRCRLF in which case the second Replace fixes
'that by changing CRCRLF to CRLF. The third Replace removes all double
'quotes.

text = fso.OpenTextFile(arg(0)).ReadAll
text = Replace(text,vblf,vbcrlf)
text = Replace(text,vbcr & vbcr, vbcr)
text = Replace(text,"""","")

'OpenTextFile returns a textstream object which is used to
'output the new data. The second parameter (2) indicates the file
'is opened for writing. The third parameter (True) says to create
'the file if it doesn't already exist.

set tso = fso.OpenTextFile(arg(1), 2, True)
tso.Write text
tso.Close
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You have to remove the code that doesn't do what you want and add the code that does.

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

If the quotes are being added by Excel on conversion and you use my script to convert instead of Excel then there should be no quotes to be concerned with. However, if you do have quotes then use the following:

set fso = CreateObject("Scripting.FileSystemObject")
set arg = Wscript.Arguments

if arg.Count <> 2 Then
    Wscript.Echo "Convert inputfile outputfile"
    Wscript.Echo "Creates outputfile from iniputfile by replacing"
    Wscript.Echo "unix line-ending (vblf)) to Windows format (vbcrlf)"
    Wscript.Quit
End If

text = fso.OpenTextFile(arg(0)).ReadAll
text = Replace(text,vblf,vbcrlf)
text = Replace(text,vbcr & vbcr, vbcr)
text = Replace(text,"""","")
set tso = fso.OpenTextFile(arg(1), 2, True)
tso.Write text
tso.Close

Note one additional change - I added

text = Replace(text,vbcr & vbcr, vbcr)

Your original input file has lines terminated with CR. The original script, if you fed it a normal Windows text file, would end up with double spaced lines because CRLF would be changed to CRCRLF. The extra line does cleanup by changing CRCR to CR. This ensures it will work on both Unix and Windows delimited files.

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

Try saving this code into convert.vbs

set fso = CreateObject("Scripting.FileSystemObject")
set arg = Wscript.Arguments

if arg.Count <> 2 Then
    Wscript.Echo "Convert inputfile outputfile"
    Wscript.Echo "Creates outputfile from inputfile by replacing"
    Wscript.Echo "unix line-ending (vblf) to Windows format (vbcrlf)"
    Wscript.Quit
End If

text = fso.OpenTextFile(arg(0)).ReadAll
text = Replace(text,vblf,vbcrlf)
set tso = fso.OpenTextFile(arg(1), 2, True)
tso.Write text
tso.Close

From the command line you can run it by

cscript convert.vbs inputfile.txt outputfile.txt

Or if you do this once

cscript //h:cscript //x:nologo //s

It will set cscript as the default script engine. Then you can run it by

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

Here's an example of adding data to a DataGridView with two columns.

Dim con As New SqlConnection("Server=.\SQLEXPRESS;Database=PUBS;Trusted_Connection=yes;")
Dim cmd As New SqlCommand("", con)

cmd.CommandText = "SELECT au_lname, au_fname FROM authors WHERE city = 'Oakland'"

con.Open()

Dim rdr As SqlDataReader = cmd.ExecuteReader

Do While rdr.Read()
    DataGridView1.Rows.Add({rdr("au_lname"), rdr("au_fname")})
Loop

rdr.Close()
con.Close()
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You shouldn't have to buy anything for hobby programming. If you want to use VB you can download the free version from Microsoft. I suggest you avoid VB6 and get a dot net version. I think C# is also free for certain versions and if you are so inclined, most versions of Python are free.

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

One more plug for Dell - we have a summer cottage in the middle of nowhere and one summer when the battery went on my laptop, Dell sent a new one by courrier within 2 days. No charge.

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

What do you mean by "scrap"? If you don't want to use email then just don't use it.

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

You could start with the w3 SQL tutorial

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

What kind of database are you trying to add to? Is it MS-SQL, MySQL, Access, etc.? While a database could be a simple text file it usually is something more complex and can not be maintained with basic text I/O. Please provide more details and we'll try to help you.

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

You can do

UPDATE MyTable
   SET user = REPLACE(user,'ZZZQQQ','')

This will remove all ZZZQQQ strings no matter where they appear in the field.

diafol commented: Nice +15
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

According to Microsoft you cannot embed a spreadsheet directly in a vb.net form, however, you can embed it in a web browser control, then embed the web browser control in your form. There is an example of how to do that in c# here that may help you to do it in vb.net.

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

Have a look at these examples in the Code Snippet section. You can find them here and here

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

I'm also partial to Dell. I have had excellent tech support and service (on the fortunately few occasions it was required). We have three Dells in our house.

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

I believe that VLC Media Player will play Real Player Files.

rubberman commented: I think you are correct. +12
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Of course they do. When my older son was about to enter school, the closest English school was built on the open-area concept because, of course, everyone knows that young children are never distracted by what's happening in other areas around them, right? We put our boys in French Immersion instead (but not just for that reason). That school has long since been revamped to eliminate the open areas.

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

Manitoba Hydro built a state-of-the-art head office in downtown Winnipeg a few years ago using the open office paradigm. They soon found that the noise from adjacent areas was too distracting and had to extend the walls around the meeting areas to the ceiling, which disrupted the airflow which relied on there being no walls.

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

Incidentally, rather than averaging the colors I read somewhere that you get a better result from

Dim r As Single = c.R
Dim g As Single = c.G
Dim b As Single = c.B
Dim d As Integer = CInt(r * 0.3 + g * 0.59 + b * 0.11)

@jc - I think the only problem was, as you pointed out, that the last statement should not have been inside the loop.Perhaps that just slowed everything down to the point where it looked like nothing was being done. There is an example here that uses a FormatConvertedBitmap. I played with it for a bit then gave up.

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

Try

Dim pic As Bitmap = New Bitmap(PictureBox1.Image)
Dim x As Integer = pic.Width
Dim y As Integer = pic.Height
Dim gray = New Bitmap(pic.Width, pic.Height)

For x = 0 To (pic.Width) - 1
    For y = 0 To (pic.Height) - 1
        Dim c As Color = pic.GetPixel(x, y)
        Dim r As Integer = c.R
        Dim g As Integer = c.G
        Dim b As Integer = c.B
        Dim d As Integer = (r + g + b) \ 3
        gray.SetPixel(x, y, Color.FromArgb(d, d, d))
    Next
Next

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

How about

Dim total As Single = 0.0

For Each line As String In TextBox1.Lines
    If IsNumeric(line) Then
        total += CSng(line)
    End If
Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You add a timer control and set Interval to 10000 (ten seconds). In the SelectionIndexChanged event handler for the fifth combobox you do

MyTimer.Start

In the MyTimer.Tick event handler you do

MyTimer.Stop
your other code
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I suspect you are updating the data in a dataset (in-memory copy of the database) but not updating the actual data in the database itself.

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

I think you can get a list of the matching tables by

SELECT MSysObjects.Name AS table_name
  FROM MSysObjects
 WHERE [Name] LIKE "DailyCashSalesRpt*"

Then you can step through the resulting records and build your delete queries. I can't test this out because I only have MS SQL installed, not Access.

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

You start by writing comments and putting them in your code. The comments should say what the code does, not how it does it. Then you remove the code. What's left is your pseudocode.

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

Perhaps it's just me but it seems like a lot of trouble to go through to avoid using the builtin My.Settings. And you have to modify the code every time you want to add a new setting.

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

Would anyone care to post a simple example of managing settings with xml serialization?

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

I find it easiest to use My.Settings. I don't know if there is an industry standard but I prefer to avoid the registry whenever possible.

J.C. SolvoTerra commented: Valuable Registry Info +3
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

the reason why I choose button is because it contain the no. of seats with the Proper alignment of seats

I can see why you might prefer buttons then. In that case you can use a modified version of the same code except that you don't need the Ignore flag. You could put each column of buttons in its own groupbox (or panel)

Private Sub Button_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click

    Dim btn As Button = sender

    'toggle the clicked button color

    If btn.BackColor = Button.DefaultBackColor Then
        btn.BackColor = Color.Red
    Else
        btn.BackColor = Button.DefaultBackColor
    End If

    'clear all the other buttons

    For Each b As Button In btn.Parent.Controls.OfType(Of Button)()
        If b.Name <> btn.Name Then
            b.BackColor = Button.DefaultBackColor
        End If
    Next

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

Here is one way (perhaps not the best way) of setting a group of checkboxes to allow zero or one selection. The example uses a GroupBox containing five CheckBoxes.

Private Ignore As Boolean = False

Private Sub CheckBox1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CheckBox1.CheckedChanged, CheckBox2.CheckedChanged, CheckBox3.CheckedChanged, CheckBox4.CheckedChanged, CheckBox5.CheckedChanged

    If Ignore Then Exit Sub

    Dim cbx As CheckBox = sender
    Dim grp As GroupBox = cbx.Parent

    Ignore = True

    For Each box As CheckBox In grp.Controls.OfType(Of CheckBox)()
        If box.Name <> cbx.Name Then
            box.Checked = False
        End If
    Next

    Ignore = False

End Sub

The reason for the Ignore flag is so you can ignore events that get triggered when you change the checkbox statuses within the loop.

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

Because the action involves making a selection, wouldn't you be better off with either radio buttons or checkboxes instead of buttons?

oussama_1 commented: thumbs up for logic +4
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

We all enjoy an up vote of course,

Well, I did give you an endorsement. That counts for something.

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

Likewise.

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

The data is always incomplete.

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

Yes, you can in the context of the question. When the question is phrased as "based on the data would you conclude that...". It's a mathematical question that is being unfairly influenced by political leanings.

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

A study was done where people were asked a mathematical question. One group had the question framed in a neutral fashion - the numbers related to the results of a test on whether or not a particular cream increased or decreased the incidence of skin rashes. The large majority of people interpreted the results correctly. The second group had the question framed differently (but with the same numbers) - the numbers related to how having a gun in the house related to your safety. Most people interpreted the numbers based on their political ideology rather than on the numbers themselves.

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

If you get a fair sampling then perhaps but if you ask a group of people who share the same biases (as a whole) then perhaps not. If you walk into a church and ask "does God exist" you will get one biased view. Ask a senior university class the same question and you will likely get a different one.

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

You could try changing your connection string to

SqlConnection("Server=.\SQLEXPRESS;Database=demo1;Trusted_Connection=yes;")

Change the server name to whatever your local installation is named.

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

Nobody can make a perfect evaluation. There are always biases. Anaïs Nin said “We don't see things as they are, we see them as we are.”

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

I would have to say that your biggest problem is that this isn't vb.net code. I'm guessing it is C#. Please let me know for sure and I'll move it to the correct forum.

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

I'm sorry sweet heart, did I venture away from your solution. Find a bug in my solution and I'll reconsider the fact you aren't just power tripping. A down vote for an alternative... grow up.

It's one thing to express an opinion. My opinion was that clear, concise code is generally better than code that is less clear. You have a different opinion. That is perfectly valid. Note, however, that I gave reasons why I believe one form is better coding whereas you chose to resort to sarcasm and put-downs. I'll leave it up to others to decide which of us needs to develop a little maturity.