|
create a program that using a combination of selection statement (if-else if/swith-case)
and loop statement(for/while/do-while).
|
|
|
|
|
You're going to fail your class. Well, you sure deserve to, at this rate. Your project is both trivial, and vague. No-one is going to do your homework for you. If you can't work it out, talk to your teacher, look at your books, or apply for an arts course ( or cut out the middle man and get a job at McDonalds )
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: apply for an arts course ( or cut out the middle man and get a job at McDonalds )
LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOLerrific.
|
|
|
|
|
Here ya go,
Do
If User = "Jieya" AndAlso AttemptedHomework Then
HasClue = True
Else
HasClue = False
Call GetJobAtMcDonalds(User)
End If
Loop Until (HasClue = True)
In your case, this would probably just be an endless loop.
Cheers
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
modified on Friday, March 20, 2009 10:03 AM
|
|
|
|
|
hello every one
i am having problem related to listview.I want to sort partivular column of listview (ascending or descending)on label mouse click event.I knew how to sort whole listview for that my code is :-
Private Sub lbl2_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lbl2.MouseClick
Try
Me.lst1.Sorting = SortOrder.Descending
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
please help.......
|
|
|
|
|
wow - are you trying to write unreadable code ? lbl2 and lst1 ?
If the list control doesn't have a property for what column to sort by, you may have to sort your data yourself and just bind to a sorted collection.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
hi
this lst1 are lbl2 shortform written for listview and labels....
|
|
|
|
|
Okay, you defined your sorting order, but you forgot to sort! Add the following:
Me.lst1.Sort()
|
|
|
|
|
hello
The solution you gave is true for sorting whole listview but what if i want to sort particular column of a listview....
Me.lst1.Sorting = SortOrder.Descending
the above syntax will sort whole listview...
but not particular column ...so
please help...
|
|
|
|
|
Sorting Listview columns in the .NET world is not simple. Let me see if I can give you the tools that I use for the same task. First, add this class to your project.
Imports System.Windows.Forms
Public Class C_ListviewComparer
Implements IComparer
#Region " Members "
Private _columnNumber As Integer
Private _sortOrder As SortOrder
#End Region
#Region " Constructors "
Public Sub New(ByVal ColumnNumber As Integer, _
Optional ByVal SortOrder As SortOrder = SortOrder.Ascending)
_columnNumber = ColumnNumber
_sortOrder = SortOrder
End Sub
#End Region
#Region " Methods "
#Region " ... Compare "
Public Function Compare( _
ByVal Lvi1 As Object, _
ByVal Lvi2 As Object) As Integer _
Implements System.Collections.IComparer.Compare
'-----------------------------------------------------
' Compare two subitem values in the same listview
' column
'-----------------------------------------------------
Select Case _sortOrder
Case SortOrder.Ascending ' Ascending sort order
Return CompareResult(SubitemValue(DirectCast(Lvi1, ListViewItem)), _
SubitemValue(DirectCast(Lvi2, ListViewItem)))
Case Else ' Descending sort order
Return CompareResult(SubitemValue(DirectCast(Lvi2, ListViewItem)), _
SubitemValue(DirectCast(Lvi1, ListViewItem)))
End Select
End Function
#End Region
#End Region
#Region " Procedures "
#Region " ... CompareResult "
Private Function CompareResult( _
ByVal FirstString As String, _
ByVal SecondString As String) As Integer
'-----------------------------------------------------
' Compare the subitem values to determine their sort
' order. For ascending sorts, the FirstString is the X
' value and SecondString the Y value. The values are
' reversed for a Descending sort.
'-----------------------------------------------------
If IsNumeric(FirstString) _
AndAlso IsNumeric(SecondString) Then
'** Numeric values
Return Val(FirstString).CompareTo(Val(SecondString))
ElseIf IsDate(FirstString) _
AndAlso IsDate(SecondString) Then
'** Date values
Return _
DateTime.Parse(FirstString).CompareTo(DateTime.Parse(SecondString))
Else
'** String values
Return String.Compare(FirstString, SecondString)
End If
End Function
#End Region
#Region " ... SubitemValue "
Private Function SubitemValue( _
ByVal Item As ListViewItem) As String
'-----------------------------------------------------
' Get the subitem text upon which the compare is based
'-----------------------------------------------------
Select Case Item.SubItems.Count
Case Is <= _columnNumber
Return ""
Case Else
Return Item.SubItems(_columnNumber).Text
End Select
End Function
#End Region
#End Region
End Class
With the above class in place, sorting listview columns becomes easy. For example, to sort ascending on column 3, use something like this.
Listview1.ListViewItemSorter = New C_ListviewComparer(3)
Listview1.Sort()
To sort descending on column 6, the code becomes as follows.
Listview1.ListViewItemSorter = New C_ListviewComparer(6, SortOrder.Descending)
Listview1.Sort()
To sort on two or more columns, sort the minor key first and then the major key. For example, to sort column 4 within column 3, do this.
Listview1.ListViewItemSorter = New C_ListviewComparer(4)
Listview1.Sort()
Listview1.ListViewItemSorter = New C_ListviewComparer(3)
Listview1.Sort()
I should probably write an article on this topic, but, I just submitted another one. Maybe this one will be next.
Hope this helps ... George
|
|
|
|
|
Okay so how to explain this..
For example,
when I place a panel on my child form, set its dock property to fill and set the panels back color to black.
and then display the child form (having defaulted it's WindowsState to maximized)
The Form Displays Maximized but the panel remains the initial size that it was in the designer(ask me to explain that again if I'm unclear). If I however set the WindowState to Maximized in the Form Load of the MDI Child, the Child Form will re size itself, OR RATHER the panel will re size itself to fill the rest of the space in the parent container. (but not with out displaying the panels initial size first,looks tacky)
Am I doing something wrong to cause this ?
What I actually want to do (and excuse me for putting this part 2nd) is to display the Child Forms in tabs, which works fine except for the problem mentioned above. However when using tabs setting the WindowState to Maximized in the Form Load doesn't re size the form or panel.
Here's the code im using to create the child form and add it to the tab contorl:
*****************************************************
Dim myTab As New TabPage("mMnewtab")
mytab.Name = "frmMdiChild"
Dim myChild As New frmMdiChild
myChild.Text = "wateva"
myChild.MdiParent = Me
myChild.Visible = True
'myChild.WindowState = FormWindowState.Maximized //makes no difference
mytab.Controls.Add(myChild)
myTabControl.TabPages.Add(mytab)
myTabControl.SelectedTab = mytab
*****************************************************
any help would be greatly appreciated, thanks !
|
|
|
|
|
I'm not sure what your problem is but in the resize event of the child form put this in to see if it will fix you issue.
If Me.WindowState <> FormWindowState.Minimized Then Me.Refresh()
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
It sounds like the panel's Anchor property is not set correctly. If the panel's Anchor property is set to Top, Bottom, Left, Right the panel should stretch when the window is maximized so that the distances between the edges of the panel and the edges of the form remain constant.
|
|
|
|
|
The application watches a folder, and moves the files to another directory, and records some info in an SQL database. The app sometimes just disappears.
It's not a complicated app. I checked to make sure I close all file handles, SQL connections, etc.
Any idea on how to find out what's going on?
|
|
|
|
|
If it was a scheduled task, then the final exit code would be available in the scheduled task window.
|
|
|
|
|
Is there a way one can start a program, then stop it (say at midnight), and restart it again?
|
|
|
|
|
dBrong wrote: restart it again?
as in: let's not debug and figure out what is wrong, let's just close our eyes?
what you need to do is:
1. add logging code, so a file tells you what is going on. Make sure to use File.AppendAllText so the file is likely closed when things go wrong.
2. try to increase activity so the problem occurs sooner, saving you some calendar time in locating and fixing the problem and testing the fix.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
What about making the task self submit itself to the task scheduler at midnight, then exit ?
I agree that finding the root cause of the shutdown is the best way, but sometimes you will spend more time than is worth it. Create a detailed log of what the application is doing is highly recommended and if you have time is the best way to go. However, you may be trying to debug this application for months without finding the root cause. A self-submitting application seems like a straight forward approach and may give you years of trouble free execution.
It's just a suggestion. Let's not get into nasty postings that don't help the situation.
Respectfully,
David
|
|
|
|
|
David Mujica wrote: What about making the task self submit itself to the task scheduler at midnight, then exit ?
This sounds like a sensible solution.
|
|
|
|
|
Instrument your code so it logs information to a file. That way you can get an idea of what your service was doing when it crashed. Another possibility would be to run a Debug version of your server, then connect Visual Studio to the running instance to so you grab any exceptions that are thrown and you can see what variables are holding which values to get an idea of what the code was thinking when it blew up.
|
|
|
|
|
I seem to recall that the folder watcher was unstable, I looked into using it some years ago and it was known issue if there were too many envents on the folder the watcher would crash. We declined to use it at that point, however that was over 4 years ago.
Instead we just used a timed read of the folder contents and processed anyhing we found. As we can process over 1200 filed in the hour FW was not an option - system has been stable for 4 years!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks. That's another good idea I can try.
|
|
|
|
|
Can the application be retasked as a service? The service can be set to auto-restart on failure.
Just a thought...
Tim
|
|
|
|
|
Another good idea. I need to see how much money the client wants to spend on this.
|
|
|
|
|
How to Display Database Reocrds using list view?
|
|
|
|