|
I don't either - generally, but this one calls methods in the class, and as far as I'm concerned, that's a no-no because it could throw an exception. IMHO, setting/getting properties should NOT be able to throw exceptions because they should always contain valid data.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I would agree; keep the property simple.
You are dealing with VB, I'm sure you will find much worse coding.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
John Simmons / outlaw programmer wrote: property that contains about 60 lines of code...
...must be changed to method. That is what I would have done. Apart from little bit code like increment/decrement or any conversion/casting if needed, I never write anything in properties.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
You want interface as lean as possible. If you need additional functions than they should be private functions in VB or static functions in your source files in C/C++. 60 lines is not that large of a function.
|
|
|
|
|
I agree with what's been said here, in summary:
get should do be limited to: minimal computation involving readily available data
set should do be limited to: minimal computation involved to transfer data to a readily available store and any relevant event handler notification.
There's nothing worse than expanding this in Visual Studio and having to wait for 5 minutes while it evaluates a bunch of properties that you likely don't care about!
|
|
|
|
|
hi i need help to how wait the process finish.
for example.
pc : is a string "contain ip pc"
position : is integer "contain index number to know how item will change the imageindex of current item in other listviewitem1
for each item as listviewitem in listview1.items
pc = item.ToolTipText
position = item.index
ping_to_host() ' here i have a sub created to ping ip and in sub he change the imageindex in the other listview ( for exmaple : 0 is "off" and 1 is "on" )
next
OK the problem is not here , the problem is when he get de position and pc name he go to the ping_to_host() sub .
this process is very fast for ping process can complete of the first ip recepted.
when he are pinging to ip "1" the process can't complete because don't have time for complete .
how i can set a time or wait to ping process complete for can jump for next item.
SORRY , SO LONG TIME NO SPEAK ENGLISH
|
|
|
|
|
Put the ping code into a thread and join the thread... That should wait for the thread to finish before processing continues.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
i don't know how to insert.
the button to shearch is here :
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim posicaoatual As String
Dim itemselecionado As String
Dim t As Thread
For Each items As ListViewItem In lstrefresh.Items
items.Selected = True
For Each selecionado As ListViewItem In lstrefresh.SelectedItems
Main.PosicaoEstacaoNoList = selecionado.Index
Main.estacaoSelected = selecionado.SubItems.Item(2).Text
Control.Ping_to_host()
't = New Thread(AddressOf processo.Ping_to_host)
' MessageBox.Show(Main.estacaoSelected & vbCrLf & Main.PosicaoEstacaoNoList)
't.Start()
Next
Next
End Sub
here i have the ping code :
Public Sub Ping_to_host()
Main.RichTextBox1.Clear()
Dim vez As String = 3
'Dim host As String = Main.estacaoSelected
Dim ip As String = Main.estacaoSelected
Dim ans, ans2
Dim i As Integer
'ans = InputBox("Digite o Endereço desejado", "Host", "www.google.com.br")
ans = ip
If ans = "" Then
Exit Sub
Else
host = ans.ToString
'ans2 = InputBox("Pro favor digite a quantidade de vezes para pingar", "Ping count", "1")
ans2 = vez
If ans2 = "" Then
Exit Sub
Else
vezes = ans2.ToString
' For i = 0 To System.Convert.ToInt32(vezes.Text)
' For i = 1 To System.Convert.ToInt32(vezes.Text)
Me.Timer3.Enabled = True
'Me.Timer3.Start()
'Next
End If
End If
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
Dim lstText As String
Dim i As Integer
'Me.Timer3.Enabled = True
'Me.Timer3.Start()
For i = 1 To System.Convert.ToInt16(vezes)
Try
If My.Computer.Network.Ping(Me.host) Then
'MsgBox("Ping successfull", MsgBoxStyle.Information, "Successfull")
lstText = Now() & " --- " & host & " -- " & "Ping OK" & vbCrLf
' MsgBox("oi")
Main.RichTextBox1.Text = LTrim(Main.RichTextBox1.Text) & lstText
'If RefreshPC.refreshPC_tipo = "RefreshAll" Then
' RefreshPC.status_ping = "ON"
'End If
stat = "on"
Else
'MsgBox("Ping unsuccessfull", MsgBoxStyle.Critical, "Unsuccessfull")
lstText = Now() & " --- " & host & " -- " & "Ping error" & vbCrLf
Main.lstestacoes.Items.Item(Main.PosicaoEstacaoNoList).ImageIndex = 1
Main.RichTextBox1.Text = LTrim(Main.RichTextBox1.Text) & lstText
End If
Catch ex As Exception
lstText = Now() & " " & host & " -- " & "Ping error" & vbCrLf
Main.RichTextBox1.Text = LTrim(Main.RichTextBox1.Text) & lstText
Main.lstestacoes.Items.Item(Main.PosicaoEstacaoNoList).ImageIndex = 1
End Try
Next
Main.RichTextBox1.Text = LTrim(Main.RichTextBox1.Text) & "Done..."
Me.Timer3.Enabled = False
RaiseEvent ThreadCompleta(stat)
'Me.Timer3.Stop()
End Sub
with need more say me please...
|
|
|
|
|
i resolved this problem using "While"
|
|
|
|
|
Hi,
Vista 32 bit machine SP2
I am using VS 2010 beta 2 on this test machine, just installed the MS SDK for 2010 beta 2 today. I am unable to find any way to get a Visual Studio command prompt to launch Ngen. It does not appear in the places MS's current on-line documentation says it should appear. It just ain't there.
Doing a search for "ngen.exe," I find nine copies of it going back to 2006, and what appear to be four identical copies of it (99k in size) in various strange folders with what look GUID's in their titles.
Sure I can get a command prompt of the usual sort the usual ways, but I am under the impression there is a special command prompt for Visual Studio : perhaps that's way off.
Appreciate any advice, best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
I found it in the Start Menu, so it should be there for you. I checked Beta 1 because I happened to have that VM running, but I'm sure it's in Beta 2 as well.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hi John,
Thanks for responding and congrats on the new job !
I have searched every cranny of the start menu under Visual Studio 2010, Microsoft Visual Studio 2010 Beta2 SDK. I have run searches "Visual Studio Command Prompt," finding nothing.
When I installed VS2010 beta2 I did not install the C/C++ facility; I am wondering if I left something out.
The only "Command Prompt" I can find is the usual one under Start/All Programs/Accessories/Command Prompt.
thanks, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
Okay, I fired up my VM with Beta 2 installed, and it's in the same place
Applications | Microsoft Visual Studio 2010 | Visual Studio Tools | Visual Studio Command Prompt (2010)<br />
The properties shows this path:
%comspec% /k ""C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86<br />
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Again, thanks, John,
Ain't hide nor hair o' that beast in my computer. I'll fire off a note to Sauron of Redmond.
best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
Hi,
I am developing a project where I need a checkbox. My problem is the Checkbox does not get a focus Rectangle when Enter Key is pressed. After searching a lot I found that I can set the focus by Overriding the ShowFocusCues() Property of the Checkbox. This works five when I make the checkbox using a class. My code is as follows:
Protected Overrides ReadOnly Property ShowFocusCues() As Boolean
Get
Return True
End Get
End Property
But the same does not work when placed in User Control. I need to set focus on checkbox when the control receives focus on pressing Enter key.
Madhu
|
|
|
|
|
You will need to expose a boolean property from your user control. Then, you can set that in the form where you are using the user control on enter keypress.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
I have tried this method also but it is not working
|
|
|
|
|
Can you show the code you are using? Also, do you just want the focus or want display cues as well?
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Override OnFocus of the user control and set focus to the check box there.
protected void OnFocus(...) {
checkBox1.Focus();
}
|
|
|
|
|
I guess OP wants checkbox to be focussed when enter key is pressed. Hence, with this approach, user control should be focussed when enter key is pressed. Then the check box will get the focus.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Hi,
I have tried this but it is not working.
Madhu
|
|
|
|
|
Can you spell out your requirements CLEARLY ? Do you want to set the focus to the check box when user presses Enter Key ? This is strange behavior, why would you want this ?
|
|
|
|
|
Hi,
I am going to develop a Customer Master form where I have several TextBox, Label, Radio Button and Checkbox. The problem that I have faced is that when the focus reaches either the CheckBox or the Radio Button by pressing enter Key not Tab Key, the Rectangular Shape (to indicate that a control has focus) does not appear. Later I found that there is a property ShowFocusCues which needs to be overridden. I tried this with Class and it works fine whereby I get the Rectangular Shape indicating that it has focus. The code used in the class is
Protected Overrides ReadOnly Property ShowFocusCues() As Boolean
Get
Return True
End Get
End Property
But my requirement is not to use it as a Class but to make a UserControl containing a Checkbox.
Now, using this control in my form I am unable to get the Rectangular Shape (to indicate that a control has focus) while I move through the different controls using Enter Key.
I hope I cld put the details now. In case you still have problem in understanding my requirement pls do tell me.
Madhu
|
|
|
|
|
The only way you can change the ShowFocusCues property is by inheriting the CheckBox control and creating your own CustomControl, which you have already done ('class' in your jargon), since it is a protected property.
You cannot put a check box in a UserControl and achieve that behavior.
Why can't you use a Custom Control ? Do you have any limitations, may be we can workaround those limitations.
|
|
|
|
|
Hi,
Thanx for ur reply. I am very new to VB.Net. So I am not much sure of the advantages and disadvantages of User Control over Class. We have been asked to use User Control in our project but probbaly if it is draw back then I can put this Issue in our next discussion.
Madhu
|
|
|
|