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

We won't do your homework here either.

AndreRet commented: indeed :) +12
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It would make more sense (to me) to have the chapters in a combobox. Selecting a new chapter would automatically open the file. You said this was for school so I am assuming it is an assignment. We don't do other people's homework for them. However, we will give help with problems you may be having. For example, are you having trouble with

  1. the file input
  2. parsing the lines in the file
  3. storing the file contents in a data structure
  4. presenting the words to the user
  5. checking the user entry against the file

I asked about NL because my grandparents came to Canada from there in the 1890s.

rumanoid commented: thanks for helping +0
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Let me see if I have this.

  1. The user selects a file from a list
  2. The file contains pairs of words. The first is in one language, the second in another
  3. The program displays the first word and a textbox for the user to type the translation
  4. The program compares the translated word to the correct word that was in the file

Input file looks like

hond,dog
venster,window
huis,house

NL as in Netherlands?

rumanoid commented: Thanks for helping +0
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Been home from the cottage since the end of August. Remember that snowstorm a week ago? We were raking leaves in the middle of it. Should have waited (like I wanted to) for the nicer weather that eventually came back.

Stuugie commented: Another Up-Vote for your help. Thanks! +2
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Hey Stuggie, how are you enjoying this crappy fall weather?

Try replacing 'm' with just the word, month as in

select DATEPART(month,release_date) from etc
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I generally try to work from the simple case to the complex one. In this case your first concern is developing an algorithm to place the ships and you are complicating it with grids, labels, etc.

I'd start with a simple 10x10 integer array. Ships (at least in the classic game) cover either 2, 3, 4 or 5 cells ann can be placed horizontally or vertically. In VB, the indices of the rows and columns will run from 0 to 9 so that is the maximum range for the random numbers. You'll have to generate three numbers for each selection. One will be the row, the next the column, and the third will indicate direction. Once you generate the direction it will determine the upper range for either the row or column as ten minus the ship width. For example, if placing an aircraft carrier (5 cells) horizontally, the first column can't exceed 5 because that would overlap the right edge of the board.

Dim board(9,9) As Integer   'the playing area
Dim row As Integer          'row number from 0 to 9
Dim col As Integer          'column number from 0 to 9
Dim dir As Integer          'direction 0=horizontal, 1=vertical

So you start with a list of ship types and continue placing ships at random until the list is exhausted. That's your outer loop. In the inner loop you generate dir, then row and col (restricting the range based on dir). All you need then is a Sub that checks …

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

I took a look at the winners and compared the code to the code I had submitted. I was reminded of a very old Doonesbury cartoon.

BD: What are you writing your term paper on?

Mike: Juxtabranchial organ secretions in the higher order mollusks. You?

BD: Our friend the beaver.

Congratulations to all the winners. Amazing pieces of code.

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

If

My.Computer.Audio.Play(My.Resources.alarm, AudioPlayMode.BackgroundLoop)
MsgBox(MessageBox.Text)
My.Computer.Audio.Stop()

works then

If cbxAudibleAlarm.Checked Then
    My.Computer.Audio.Play(My.Resources.alarm, AudioPlayMode.BackgroundLoop)
End If

MsgBox(MessageBox.Text)

If cbxAudibleAlarm.Checked Then
    My.Computer.Audio.Stop()
End If    

should also work

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

It's possible. For sample code please see this thread.

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

I think what you are looking for is a Masked Text Box.

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

I would define a class level variable to hold the countdown value.

Private countdown As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim btn As Button = sender

    If btn.Text = "Start Timer" Then
        countdown = 100
        btn.Text = "Stop Timer"
        TimerState.Text = "Active"
        Timer1.Enabled = True
    Else
        btn.Text = "Stop Timer"
        TimerState.Text = "Inactive"
        Timer1.Enabled = False
    End If

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    countdown -= 1
    txtTimer.Text = timeout

    If countdown = 0 Then
        timer1.Enabled = False
        My.Computer.Audio.Play(My.Resources.alarm)
        MsgBox(MessageBox.Text)
        TimerState.Text = "Expired"
    End If

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

That will tell you whether the machine is on the network but does not tell you if the server is up. Of course, "up" is open to interpretation. If you are running multiple services (FTP, WEB, etc) what can be non-responsive before it is considered not to be up?

Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
  1. This thread is old. Don't revive it.
  2. Your answer has nothing to do with the question.
  3. Your code isn't VB code.
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You put a button under each column. When the user clicks a button (selects a column), the program "drops" a token for the user into that column. If you are animating the token then you can disable the buttons until the token has fallen. Then you re-enable any buttons for columns which are not full. You can use the same handler for all buttons. If you have named the buttons like btnCol1, btnCol2, etc. then you can determine the clicked column by getting the name of the button inside the handler. Here's an example using three buttons.

    Private Sub Button_Click(sender As System.Object, e As System.EventArgs) Handles btnCol1.Click, btnCol2.Click, btnCol3.Click

        Dim col As Integer = CInt(sender.name.Substring(Len(sender.Name) - 1))
        MsgBox("You clicked column " & col)

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

You could try

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

    Dim col() As String = {"", "", "", "", ""}
    Dim fld() As String = line.Split(vbTab)

    For i As Integer = 0 To UBound(fld)
        col(i) = fld(i)
    Next

    For i As Integer = 0 To UBound(col)
        Debug.WriteLine(" field " & i & " = " & col(i))
    Next

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

I attached a sample project that implements a command shell inside a Windows form. I hope this helps.

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

By the way

Dim lviNew As New ListViewItem
With lviNew
    .Text = EmpNumTextBox.Text
    .SubItems.Add(dates.Text)
    .SubItems.Add(timein.Text)
End With
TimeSheetListView.Items.Add(lviNew)

can be written as

TimeSheetListView.Items.Add(New ListViewItem({EmpNumTextBox.Text,dates.Text,timein.Text}))
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

And as far as I know, there is still not a version of wxPython available for Python 3.x

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

In that case you add a switch to sort to specify the starting column number as in

tasklist /nh | sort /+30
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'd like to suggest a small change to the way "Replies" are handles in the PM section. I like that when I reply to a PM, the subject line gets changed from "Original Title" to "Re: Original Title", but when there are several back-and-forths on the same topic, the title ends up looking like "Re: Re: Re: Re: Original Title". How about not adding extra "Re:"s when the title already starts with "Re:"?

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

In the GUI, click on that column. If you are running it from the command line then

tasklist /nh | sort
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Maybe not as simple as you'd like but what I'd do is

Inventory

  • ProductID (PK)
  • ProductCode
  • SerialNumber
  • Cost
  • ProductName
  • Description

Customer

  • CustomerID (PK)
  • CustomerName
  • CustomerAddress

Orders

  • OrderID (PK)
  • CustomerID (FK)
  • OrderDate
  • Tax
  • TotalCost

OrderItems

  • OrderID (PK/FK)
  • LineID (PK)
  • ProductID
  • Quantity
  • TotalCost

PK = Primary key, FK = foreign key. ProductID, CustomerID and OrderID would be IDENTITY fields (generated by the database or application and guaranteed to be unique). These could start at 1 and auto-increment. LineID could start at 1 for each new order and auto-increment.

Each order has its unique OrderID. The OrderItems table contains all of the items ordered by the customer. For this table you use a compound key (OrderID/LineID) so guarantee a unique key value. Some fields (like CustomerAddress) could be split into multiple fields, say, for city, street, etc. You'd probably add other fields such as telephone number. Orders would also likely have fields for OrderStatus, ShippingAddress, DeliveryDate, etc.

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

I'm not a C++ programmer (although I have done a fair bit of development in C), but I think you will have an easier time developing the code in Python. Because your GUI is fairly simple perhaps I will recant my earlier warning and suggest you develop the GUI first with stubs for the rest. You can always post questions in the Python forum if you are having problems with the GUI. To be fair, my experiences with Python GUIs were with the wxPython package and my main problem was with the resizers which you may not need. As an assembler programmer you are obviously not afraid to get your hands dirty.

BigPaw commented: Jim read Though and around my problem, and then followed up with well considered suggestions. I reached a positive solution with Jims help. +0
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

At the risk of offending pyTony, I'd say avoid Python simply because of the problems building the GUI. I find Python to be an excellent (even elegant) language, but I found that building a GUI was excrutiatingly painful. For someone who is already familiar with Python I'd say go ahead but not for someone who is a newbie to it. I can't speak for C++ but if you are using an IDE such as Visual Studio I'd say go ahead with C++ or Visual Basic.

By the way, if you indent a line (tab or four spaces) the editor treats it as code (which is automatically numbered). If you don't indent the line then it is treated as straight text. You can click on formatting help at the top right of the edit window for help.

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

To everyone who is posting in this two-year old thread

  1. Please do not resurrect old threads. If you have a question then start a new thread
  2. Don't ask for a complete solution. You won't get it.

DaniWeb is not the place to go if you want someone to do your homework for you. We will help you if you are having specific problems (algorithm, Controls, etc) but we will not do the work for you. If this is your final project and you don't have a clue where to start then you obviously have not learned the course material and deserve to fail.

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

Assuming you want to display seconds, create a timer on the form, set the interval to 1000 (one second in milliseconds), then in the timer event handler, write the current time into a label. Make sure you set the Enabled property of the timer to True at some point (form load perhaps) to start the time update.

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        lblTime.Text = TimeOfDay
    End Sub
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The up/down arrows could continue to function as an anonymous voting scheme AND as a way to vote with a comment via the following test on click

if Trim(comment) is null then
    apply anonymous voting (no change to rep)
else
    submit comment and alter rep

Wouldn't that eliminate the confusion as well as preventing lost comments?

WaltP commented: My suggestion EXACTLY +0
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

War of the Worlds - I wish they'd make one faithful to the book. Both movies were heavily Americanized and Spielberg had to add his "broken family" signature which I think is getting a little old.

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

Your select is

select last_name, first_name, middle_name

None of those items is the contact_number. Try changing your select to

select last_name, first_name, middle_name, contact_number
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Shouldn't there really be a HELP or HOWTO or FAQ link displayed prominently in one of the toolbars that takes users (especially helpful for new users) to a page that explains stuff like this? New users need to know things like

  1. how the voting system works
  2. what the icons next to thread titles mean
  3. why they can't send PMs immediately
  4. what happens when they click on a thread title or the last posted date

It doesn't have to be a hundred page user manual but surely one or two pages of notes would be better than having to explain it again and again in the fora. At least then if the questions persist they could be answered with a simple reference to the FAQ page.

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

I've said this before - I'm not well versed in DataTables, DataAdapters, DataSets, etc but I think I can take a few educated guesses. You declare ds at the class level and you fill it in sReadDbf but in that sub you do

Dim ds As New DataSet

so the actual "ds" that you are using in sReadDbf is a copy local to that sub. try replacing

Dim ds As New DataSet

with

ds = New DataSet

That way you will be using the same "ds" in both subs and when you reference it in sWriteAccess it will retain all the properties from when you filled it in sReadDbf.

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

Once I understood how the voting worked I found it to be very easy. I'd rather see it stay the way it is than go to a popup.

WaltP commented: Me too. +0
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I thought that the 'ds' was available when I declared it as a Public declaration at the top of my code

That may be true, however I can't see the top of your code that includes public declarations. All you posted were the two subs, one of which instantiates its own copy of ds and one that doesn't. And on the Public declaration did you just declare ds or declare it and create it as New?

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

An oldie but a goodie "Penn & Teller Get Killed". There is an absolutely hilarious scene going through the metal detector at the airport. And if you like Penn & Teller, the first two seasons of Penn & Teller's BullSh!t are very well done. For anyone unfamiliar with it, they examine various things to determine whether they have merit or not. The segment on bottled water was revealing.

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

brylle - exactly how does your code accomplish what was asked? In English it becomes

If char is not a digit Then
    ignore this keypress
End If

If char is backspace Then
    don't ignore this keypress
End If

What you have posted does the complete opposite of what was asked. If you want code that is even simpler than what I already posted then you can use

Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    If Char.IsDigit(e.KeyChar) Then e.Handled = True
End Sub

I think the only way to simplify this further is

Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    e.Handled = Char.IsDigit(e.KeyChar)
End Sub
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

There are very few things in life that are a choice... We as humans are tempered by our desires.

I strongly disagree. People who say "I had no choice" when things go bad are really saying "I knew it was wrong and I did it anyway". If I spend five hours a night in front of the TV instead of trying to better myself either mentally or physically then that is my choice. If I drink six bottles of Coke a day and scarf down doughnuts at the office then develop diabetes as a result of my obesity then that was my choice. If I spend $400 a month on booze (as my friend was doing) instead of paying off my credit cards and mortgage then that is my choice. If I buy a status car like a Mercedes or BMW, or a gas guzzling SUV that I can't afford instead of a cheaper car (or a bike or a bus pass) that I can, then that is my choice. I choose whether to spend $40 on a nice restaurant meal or prepare a meal at home for a fifth of the cost. If I have a desire then I choose either to act or not to act on it.

Granted there are some choices that are actually no choice at all. For an poor inner city kid the choice may be get with a gang or get dead. Not a lot of choice involved there.

addiction …

Xantipius commented: up +0
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Not quite correct. The select should be

sql = "SELECT Position from tblLogin WHERE username = '" & txtUsername.text & "'"

and somewhere, sometime, somehow, someone is going to mention how you should be using parameter entry instead of concatenation to protect against SQL injection attacks.

BitBlt commented: You're right, good catch. On both items :-) +8
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

So it's not Python 4.0 then?

~s.o.s~ commented: haha, that's a nice one +0
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

In 2011, America's top thirteen hedge-fund managers earned an average of $1 billion each. One of them took home $5 billion. Much of their income is taxed as capital gains - at 15 percent - due to a tax loophole that Republican members of Congress have steadfastly guarded.

If the earnings of those thirteen hedge-fund managers were taxed as ordinary income, the revenues generated would pay the salaries and benefits of 300,000 teachers. Who is more valuable to our society - thirteen hedge-fund managers or 300,000 teachers?

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

I know SOPA is dead (for now) but Under SOPA you could get five years in jail for uploading a Michael Jackson song - one year more than the doctor who killed him.

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

I don't know what the target system is but it sounds like an access rights problem. It could be that the folder containing the database is restricted to read only. Or it's possible that the database file itself has insufficient access rights. You could try taking ownership of the file or nake the file available to everyone. The easiest way to do this is to open a command shell (cmd.exe) as Administrator, navigate to the folder with the database file then type the following command (replacing dbfile.acc with the actual database file name)

cacls dbfile.acc /e /g everyone:f

the /e means "edit" the existing access rights instead of replacing them
the /g means "grant" the following access rights
and everyone:f means everyone on this computer gets full access

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

This might be a little shorter and clearer

        Dim aa As New Collection
        Dim bb As New Collection

        For Each user As String In {"Abe", "Bob", "Jim"}
            Select Case UCase(user.Substring(0, 1))
                Case "A" : aa.Add(user)
                Case "B" : bb.Add(user)
            End Select
        Next

But a more general approach using a dictionary looks like

        Dim names As New Dictionary(Of String, Collection)

        For Each user As String In {"Abe", "Bob", "Jim"}

            Dim firstLetter As String = UCase(user.Substring(0, 1))

            If Not names.ContainsKey(firstLetter) Then
                names.Add(firstLetter, New Collection)
            End If

            names(firstLetter).Add(user)

        Next

        For Each letter As String In names.Keys
            Debug.WriteLine("Names starting with the letter " & letter)
            For Each name As String In names(letter)
                Debug.WriteLine(vbTab & name.ToString)
            Next
        Next
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

@pritaeas - Saw the first installment of Berserk: The Golden Age Arc - The Egg of the King last night. I think you'd enjoy this one. There are three movies plalnned ini the arc. So far only the first has been released.

pritaeas commented: Thanks +0
RobertHDD commented: Your pretty smart Jim +0
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Then you might consider putting all of the textboxes into a GroupBox and doing the following

Dim sum As Double = 0.0

For Each tbx As TextBox In GroupBox1.Controls.OfType(Of TextBox)()
    If tbx.Text <> "" AndAlso IsNumeric(tbx.Text.Substring(1)) Then
        sum += CDbl(tbx.Text.Substring(1))
    End If
Next

MsgBox("sum is " & sum)
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You could do

label7.Text = CDbl(textbox1.Text.Substring(1)) _
            + CDbl(textbox2.Text.Substring(1)) _
            + CDbl(textbox3.Text.Substring(1))

etc. This assumes that there are valid values in all of the textboxes. Proper code should do error checking.

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

The way communism was supposed to work was "from everone according to their ability and to everyone according to their need". That was the theory. In practice it always seemed to work out that those in power got and those who weren't didn't.

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

Anthony Burgess created the dialect (NADSAT) that is also used extensively in the movie. It brings to mind another oldie but goodie. Quest For Fire. It was a joint production between Canada and France. Anthony Burgess created the primitive language for the early humans in this prehistoric adventure about a trio of warriors who travel the savanna, encountering sabre-toothed tigers, mammoths and cannibalistic tribes in search of a flame that would replace the fire their tribe has lost. There are no subtitles.

I think Shawshank Redemption is as close to a perfect movie as it gets. I don't care what they say about Citizen Kane (brilliant) or Vertigo (meh). Shawshank Redemption beats them both.

pritaeas commented: ATTR! +0
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

What diafol said. Apparently some people can take a hint only if it is applied with a sledge-hammer.

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

but when you come to know that he dont have any worth of you and even laugh when you show respect to them, then that is a pathetic situaion. what about this ?

I suppose you can conclude that the relationship is not what you had assumed and move on. Just because this other person is not interested in the same sort of relationship that you are doesn't mean that he/she considers you worthless.

when anyone is helpful to you alot(just like you , for example), you get attached to that person

Sometimes people just want to help without entering into a personal relationship. What you get out the relationship is help with a technical problem. What I get out of it is a feeling of satisfaction that my skills are being put to use and the good feeling that comes from helping others.

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

You should determine whether this is a perceived (by you) slight or an actual slight. If it is actual then you should ask yourself if it was dererved. Was it caused by a specific act or series of acts on your part? Was the person who slighted you the target of your unwanted attention? Are you fixated on this person in a creepy way, such as, perhaps, by adopting the same avatar? If this was a face=to-face relationship and you started dressing and acting like the other person this would be seriously weird.