|
If I remember correctly, extension methods cannot be targeted for version 2 (for example extension attribute was introduced in 3.5). Have a look at this article: Extension Methods (Visual Basic)[^].
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
It seems I was being particularly dense yesterday afternoon. The reason I couldn't get this to work was that I was actually using VS 2005 instead of VS 2008.
The above code snippets work correctly when targeting .NET 2.0 in a VS 2008 project
Thanks,
dlarkin77
|
|
|
|
|
Does anyone know how to get it put into a web page i made it it works when i run it using VB6.0 it opens an IE windows and performs exactly as desired its a standalone so its not that hard i just dont know how to put it on the web for people to use any information would be great a link to anothe rsite on activeX components
the program is simple only a couple lines of code does not need to connect ao server of any kind just need help getting it onto a web page thank you for your time
|
|
|
|
|
I think you want to look into the OBJECT tag. Here...[^]
|
|
|
|
|
Hi,
I don't know if it is a good practice what I am doing here.
I have a class that is making the connections to the database. The connection string I save in the web.config.
And this is the property that I used inside that class to get the connectionstring.
Does it make sense?
''' <summary>
''' This variable holds the db connection string.
''' The value of the db connection string is saved in the web.config.
''' </summary>
Private Shared sConString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ConnectionString
Private Shared ReadOnly Property ConString() As String
Get
Return sConString
End Get
End Property
|
|
|
|
|
Making the property private is pointless as the only thing that access to the property also has access to the original string. Other than that, looks okay.
|
|
|
|
|
So, it is better that I use only
Private Shared sConString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ConnectionString
Isn't that so that every time I ask for sConString, he will lookup the connection string in the web.config?
Or I can do the following ?
Private Shared sConString As String = ""
Public Sub New()
sConString = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ConnectionString
End Sub
|
|
|
|
|
ESTAN wrote: Isn't that so that every time I ask for sConString, he will lookup the connection string in the web.config?
No. It won't. Think about what you are actually doing. You have a shared field on the class. It has no functionality, it is just a reference to an area of memory that stored the connection string.
ESTAN wrote: Or I can do the following ?
Private Shared sConString As String = ""
Public Sub New()
sConString = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ConnectionString
End Sub
You can, but I don't see the point.
|
|
|
|
|
Thanks, than I will keep only the 'reference' to this object.
Private Shared sConString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ConnectionString
|
|
|
|
|
They both accomplish the same thing. If you have multiple constructors, then you have to reduplicate the "sConString = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ConnectionString" line for each constructor.
I prefer 'Private Shared sConString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ConnectionString' because I am lazy.
Cheers!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
I am trying to schedule a program I wrote to run after hours when I am not actually logged onto my machinge. The code works fine while I am testing it, but it doesn't run when I schedule it. It appears to be an issue with the focus of the windows, but I am not sure how to correct it. I think sendmessage() might work, but not sure how to convert my send.keys code to send message. Can anyone show me how to conver the follwoing code so that it will run even if I am not logged on to the PC?
CODE:
Imports Microsoft.VisualBasic.Devices
Module Module1
Sub Main()
Dim ProcID As Integer ' Start the EXTRA
Dim counter As Integer = 0
Dim check As Boolean = True
ProcID = Shell("EXTRA.exe", AppWinStyle.NormalFocus) ' Activate the Calculator application.
AppActivate(ProcID)
My.Computer.Keyboard.SendKeys("WFA_DO_CP.edp{Enter}", True)
System.Threading.Thread.Sleep(5000)
My.Computer.Keyboard.SendKeys("na50{Enter}", True)
System.Threading.Thread.Sleep(1000)
My.Computer.Keyboard.SendKeys("loadbal1loadbal1{Enter}", True)
System.Threading.Thread.Sleep(2000)
My.Computer.Keyboard.SendKeys("/for vgs1sign{enter}", True)
System.Threading.Thread.Sleep(2000)
My.Computer.Keyboard.SendKeys("loadbal1loadbal1{Enter}", True)
System.Threading.Thread.Sleep(1000)
Do
Do While counter < 10
counter += 1
If counter = 1 Then
AppActivate(ProcID)
My.Computer.Keyboard.SendKeys("{home}goqsre{enter}", True)
System.Threading.Thread.Sleep(1000)
My.Computer.Keyboard.SendKeys("{tab}132_dd{tab}vggdtldd{tab 2}ctr_supv", True)
My.Computer.Keyboard.SendKeys("%(T){enter}", True)
System.Threading.Thread.Sleep(1000)
My.Computer.Keyboard.SendKeys("OQS to Excel 2000{tab}{enter}", True)
System.Threading.Thread.Sleep(360000)
ElseIf counter = 2 Then
AppActivate(ProcID)
System.Threading.Thread.Sleep(1000)
My.Computer.Keyboard.SendKeys("/for goqsre{enter}", True)
System.Threading.Thread.Sleep(1000)
My.Computer.Keyboard.SendKeys("{tab}731_dd{tab}vggdtldd{tab 2}ctr_supv", True)
My.Computer.Keyboard.SendKeys("%(T){enter}", True)
System.Threading.Thread.Sleep(1000)
My.Computer.Keyboard.SendKeys("OQS to Excel 2000{tab}{enter}", True)
System.Threading.Thread.Sleep(360000)
ElseIf counter = 3 Then
AppActivate(ProcID)
System.Threading.Thread.Sleep(1000)
My.Computer.Keyboard.SendKeys("/for goqsre{enter}", True)
System.Threading.Thread.Sleep(1000)
My.Computer.Keyboard.SendKeys("{tab}132_ptd{tab}vggd1xdd{tab 2}ctr_supv", True)
My.Computer.Keyboard.SendKeys("%(T){enter}", True)
System.Threading.Thread.Sleep(1000)
My.Computer.Keyboard.SendKeys("OQS to Excel 2000{tab}{enter}", True)
System.Threading.Thread.Sleep(360000)
ElseIf counter = 4 Then
AppActivate(ProcID)
System.Threading.Thread.Sleep(1000)
My.Computer.Keyboard.SendKeys("/for goqsre{enter}", True)
System.Threading.Thread.Sleep(1000)
My.Computer.Keyboard.SendKeys("{tab}731_ptd{tab}vggd1xdd{tab 2}ctr_supv", True)
My.Computer.Keyboard.SendKeys("%(T){enter}", True)
System.Threading.Thread.Sleep(1000)
My.Computer.Keyboard.SendKeys("OQS to Excel 2000{tab}{enter}", True)
System.Threading.Thread.Sleep(360000)
check = False
Exit Do
End If
Loop
Loop Until check = False
End Sub
End Module
|
|
|
|
|
I don't want to be the one to aske the obvious question - but I'm going to.
Why are you not using the Windows Task Scheduler?
|
|
|
|
|
I am using windows task scheduler. However it will not run the program properly becasue it does not seem to maintain focus on the proper window. From reading so posts online if doesn't seem the the sendkeys function works when you pc is "locked." I understand that but not sure how to covert the sendkeys function to something that will worked even if the PC is locked.
|
|
|
|
|
Okay - The next question: Why does an application that is lauched from the task scheduler have a user interface? If you have a user interface for configuration then set up a command line argument that the Task Sdheduler uses to suppress the user interface.
|
|
|
|
|
Ditto. Start the app without an interface using the command line args to drive the operations you need to perform.
my.Application.CommandLineArgs
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
What the program does is launch an application, then logs-in and runs 4 reports. The problem I have is that I used the sendkeys to log in and run the reports, but from my understand this function does work if I am not logged into the PC (a focus issue). So I am trying to see how to convert sendkeys to something that will work even if I am not logged in.
|
|
|
|
|
farmer wrote: What the program does is launch an application, then logs-in and runs 4 reports. The problem I have is that I used the sendkeys to log in and run the reports, but from my understand this function does work if I am not logged into the PC (a focus issue). So I am trying to see how to convert sendkeys to something that will work even if I am not logged in.
Then start your app like such through task scheduler: "c:\program files\AutoApp.exe" -admin -r1 -r2 -r3 -r4
Inside the app during the constructor or form load, you need to check to see if there are command line args. If there are, you need to loop collection of startup arguments and process the input as required. If -Admin is present, log in as your account. Run each report as specified (like -r1, -r2, etc).
Once your batch processing is completed, kill the app and the form is never displayed. SendKeys is not necessary nor should it be used for this type of functionality.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
as others have said, using command line arguments would be much easier. make the user name and passwords part of the command line argument and then there is no need for a user interface.
|
|
|
|
|
farmer wrote: from my understand this function does work if I am not logged into the PC (a focus issue).
No, it's not a focus issue. The issue is that you are trying to use the user interface to interact with another application, but there is no user interface at all. You can't set focus to a window when there are no windows.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi all,
I have one textbox,called Name which is validated for not blank.
Error msg: txtbox not blank.
if click the submit button,the validation applies and eerrror msg. displays --txtbox not blank.
and the cursor is out from the textbox.
my problem is ,after i got the error msg. the cursor will be placed in the textbox name.
i am using
txtname.Focus() but still it is not working.
If txtname.Text.Trim.Equals("") Then
lblError.Text = "Please enter Name."
lblError.Visible = True
txtname.Focus()
Exit Sub
End If
Thanks in advacce
mahaboobs
|
|
|
|
|
You've already done it correctly if this was a Windows Forms app. I take it, from your "JavaScript" post, that this is a Web Forms (ASP.NET) app?? You may want to ask this question in the ASP.NET Forum.
|
|
|
|
|
Hi,
I am writing a code for a calculator.
My problem is:
when I calculate with
Windows Calculator
I get:
Math.Sqrt(69) = 8,3066238629180748525842627449075
8,3066238629180748525842627449075² = 69
when I do the same in my code in
vb.net 2005 (Variables are Decimal)
I get:
Math.Sqrt(69) = 8,30662386291807
8,30662386291807² = 68,9999999999999
Is there any chance to get the same as in win.cal
Thanks
housekeeper
|
|
|
|
|
U can use a object to store a content otherwise copy the ans to string variable then paste into textbox. Maybe it will work.... Try it if it work reply me.
Thanx's
Rao.
|
|
|
|
|
Square roots are just the estimated values and not the exact one. In case you need more accurate results, I guess you will need to write your own logic.
As far as square root of 69 is concerned, double just works fine for me.
|
|
|
|
|
It's because of the way that floating point numbers are stored and handled in binary.
Just like in decimal, there are some numbers that can't be written down exactly - For example one third is 0.33333 (with repeated 3's forever). So you have this problem:
(1/3) * 3 = 1
but
0.33333 * 3 = 0.99999
To be able to write one third correctly as a decimal number you would need to write infinite 3's after the decimal point. Numbers like this are described as being 'unrepresentable'. It gets worse in binary. In binary many more numbers are unrepresentable. In binary 0.1 is unrepresentable!.
So that value stored in a floating point variable may not be exactly the required value. The decimal type in C# is meant to help with problems like this, but it's not perfect because ultimately some numbers are unrepresentable in decimal too.
You should do some reading about the problems and solutions for floating point number calculations.
There are a few articles on CP that might get you started:
http://www.codeproject.com/KB/dotnet/ExtremeFloatingPoint1.aspx[^]
http://www.codeproject.com/KB/recipes/float_point.aspx[^]
And wikipedia has some information on float point accuracy:
http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems[^]
Windows calc might just be getting it right by chance because it is storing more decimal places. Or it might just be rounding the answer up to make it look correct. Or it might be using more complex number storage/handling to arrive at a more accurate answer.
Writing a truly accurate calculation system is not an easy task. If you really want to be 100% accurate you need to do a lot of study, or consider looking at buying proper numerical analysis software[^]. You might find some of them are open source, which could help give you some tips if you really want to write your own.
Simon
|
|
|
|