|
Creating a connection is causing the overhead of having a three-way handshake. So basically, if you don't close and re-open the connection you will not have this overhead.
I don't know if you use an IP-address to connect or a DNS name, if you're using DNS, this is causing more overhead too, because you have to query for the IP-address too.
You're right when you are saying that it is annoying having to reconnect, plus it costs more time and memory to reconnect at every request.
WM.
What about weapons of mass-construction?
|
|
|
|
|
Hi,
I would like to add some shortcuts to my application in which multiple keys can be pressed to do some action or another. This wors fine for single button or ctrl/alt/shift combinations, but how can I handle other keys, like a combination of 'A' and 'Y' for example? Do I have to keep track of this manually in the key up / key down events? I'd expect there's some convenient way of handling this, but can't seem to find any info on this on msdn or google...
Cheers,
Benny
|
|
|
|
|
i was trying to change the tempo of a midi file while playing
but was unable to find a way
can you help
thanks
|
|
|
|
|
Hello
I´ve got a string and i would like to convert into an int but the problem is that when i don´t have an int an exception is throw (FormatException). How can i catch this expceion? The try{catch(Exception e) doen´t work.
I use System.Convert.ToInt32(string).
Thank you in advance,
Borja Riesgo Juan
|
|
|
|
|
Hello,
Try catch should work in this case, but is not recommended.
Instead you should use the int.Parse Method.
All the best,
Martin
|
|
|
|
|
Martin# wrote: Instead you should use the int.Parse Method.
I think that you mean the int.TryParse method, as the int.Parse method doesn't offer anything over Convert.ToInt32.
For framework 1.x you use double.TryParse with NumberStyles.Integer and then cast the value to int.
---
b { font-weight: normal; }
|
|
|
|
|
Hello Guffa,
Thank you for your info.
I normaly work with double.TryParse(), but I never tried the NumberStyles.Integer.
So I guess you would also recommend using double.TryParse plus cast to int, instead of try catch with Convert.ToInt32.
So I think I'm going to change some of my code.
So once again thanks for your help.
All the best,
Martin
|
|
|
|
|
Martin# wrote: So I guess you would also recommend using double.TryParse plus cast to int, instead of try catch with Convert.ToInt32.
Yes. Exceptions are mainly for unexpected situations. If you expect something to happen, you should try to stop it before it happens.
Another alternative is to use a regular expression to validate the string before you convert it. If you have verified that a string only contains digits and not more than fits in the range of an int, you can safely convert it to an int.
---
b { font-weight: normal; }
|
|
|
|
|
hi
can i use C++ program function in c#.Net2003 application
Thanks
|
|
|
|
|
do u want to run it from C# or embeded it in the application
|
|
|
|
|
hi,
thanks for reply
i have one program that contains some functions,
i want to use that function in my c#.net2003
it's is possible or not
plz give suggestion
or send any help full links for that .
u know how top write serialport programming in C#.net2003 and framework 1.1
using win32 API's
plz send sample code for that
Thanks
|
|
|
|
|
Hi, why doesn't my code work? I have two forms in my windows application, I want the user to click on a button called btnCustomize and the other form (called frmCustomize) to open. The first form is called reminder.
Here is the code that I have tried :
private void btnCustomize_Click(object sender, EventArgs e)
{
frmCustomize.Show();
}
I have also tried variations on this like .ShowDialog(); and such.
Can you help?
|
|
|
|
|
Wolf92 wrote: why doesn't my code work?
What exactly does that mean? Are you getting any exceptions?
Did you eventually forget to create an instance of the form and assign it to the frmCustomize field.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I think I am typing in the wrong code? I want that when the user clicks 'btnCustomize' the form 'frmCustomize' displays.
What is the code for this?
This is the error message I get when I type in :
private void btnCustomize_Click(object sender, EventArgs e)
{
frmCustomize.Show();
}
It says :
Error 1 An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Show()' D:\Documents and Settings\Sophie\My Documents\Programming\Programs\C#\Reminder\Reminder\reminder.cs 66 13 Reminder
|
|
|
|
|
You have to create an instance of your custom form on which you can call Show afterwards.
MyForm myFormInstance = new MyForm();
myFormInstance.Show(); I suggest you do some reading on OOP.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Stefan Troschütz wrote: I suggest you do some reading on OOP
that right cuase when u work with C# u should look to everything form OOP view
the form u created is a class inherteted form WindosForm class and all other objects r the same
|
|
|
|
|
Thank you! I have it working properly now. I tried something like that, but it didn't work. Thank you!
|
|
|
|
|
Hi
Plz tell me what is min requirement to run the c# project devloped at .net2003
Parshant
|
|
|
|
|
Basis of the minimum requirements are those of the used .NET framework: .NET Framework System Requirements[^]. Any further restriction depends upon your app.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi
I devolped an application .And i used png image files.When i run at the desktop it display exception "file not found"(for png ,that are exist at the exe file path).
when i paste png folder at desktop it runs.
How can i run without paste png folder
i write the path for png is
btn_main_select_file.BackgroundImage=System.Drawing.Image.FromFile(Application.StartupPath+@"\dbxpngs\select01.png");
Parshant
|
|
|
|
|
Parshant Verma wrote: When i run at the desktop
I guess that means you have a link on your desktop that targets your application executable. Open the properties window of the link and insert the application path in the "Execute in" field (not sure if it has this exact name cause I have a german OS but it should be something similar).
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
I have a couple of VBA modules I need to convert to C# (Or a SQL 2005 UDF if that is a better place for it!).
The VBA code is below:
Function RMSBetaDist(x, alpha, beta, rate)
'Main function where the cumulative Beta distribution is assembled
datasize = Range("Datsize")
Dim bt() As Double
Dim RMSBeta() As Double
Dim i As Integer
ReDim bt(datasize)
ReDim RMSBeta(datasize)
For i = 1 To datasize
If x(i, 1) < 0 Or x(i, 1) > 1 Then
'Error = MsgBox("There is a problem with the x value of the beta function", vbOKOnly)
'GoTo Abend
x(i, 1) = 1
End If
If x(i, 1) = 0 Then
bt(i) = 0
RMSBeta(i) = 0
GoTo Nextarray
ElseIf x(i, 1) = 1 Then
bt(i) = 0
RMSBeta(i) = 1
GoTo Nextarray
Else
bt(i) = Exp(RMSGammaln(alpha(i, 1) + beta(i, 1)) - RMSGammaln(alpha(i, 1)) - RMSGammaln(beta(i, 1)) + alpha(i, 1) * Log(x(i, 1)) + beta(i, 1) * Log(1 - x(i, 1)))
End If
If x(i, 1) < (alpha(i, 1) + 1) / (alpha(i, 1) + beta(i, 1) + 2) Then
RMSBeta(i) = bt(i) * RMSBetaCF(x(i, 1), alpha(i, 1), beta(i, 1)) / alpha(i, 1)
Else 'symmetry relation I(a,b)=1-I(b,a) where I() is the incomplete beta function
RMSBeta(i) = 1 - bt(i) * RMSBetaCF(1 - x(i, 1), beta(i, 1), alpha(i, 1)) / beta(i, 1)
End If
Nextarray:
RMSBetaDist = RMSBetaDist + rate(i) * (1 - RMSBeta(i))
Next i
Abend:
End Function
And the next one:
Function RMSGammaln(xg) 'Lanczos gamma approximation
'Used in the Beta distribution approximation
Dim y, temp, serial, PI, small As Double
Dim coeff(6) As Double
Dim j As Integer
PI = 3.14159265358979
coeff(0) = 76.18009173
coeff(1) = -86.50532033
coeff(2) = 24.01409822
coeff(3) = -1.231739516
coeff(4) = 0.00120858003
coeff(5) = -0.00000536382
small = 0
If xg < 1 Then
small = xg
y = xg - 1
Else
y = xg - 1
End If
temp = y + 5.5
temp = temp - (y + 0.5) * Log(temp)
serial = 1
For j = 0 To 5
y = y + 1
serial = serial + coeff(j) / y
Next j
If small <> 0 Then 'formula for values of x < 1
RMSGammaln = -temp + Log(Sqr(2 * PI) * serial)
Else
RMSGammaln = -temp + Log(Sqr(2 * PI) * serial)
End If
End Function
And the last one:
Function RMSBetaCF(x2, alpha2, beta2)
'Used to approximate the integral portion of the cumulative Beta distribution
Dim errorf As Double
Dim qap, qam, qab, em, temp, d As Double
Dim bz, bm, bp, bpp As Double
Dim az, am, ap, app, aold As Double
Dim m, MaxIterations As Integer
errorf = 0.0000001
MaxIterations = 1000
bm = 1
az = 1
am = 1
qab = alpha2 + beta2
qap = alpha2 + 1
qam = alpha2 - 1
bz = 1 - qab * x2 / qap
For m = 1 To MaxIterations
em = m
temp = em + em
d = em * (beta2 - em) * x2 / ((qam + temp) * (alpha2 + temp))
ap = az + d * am
bp = bz + d * bm
d = -(alpha2 + em) * (qab + em) * x2 / ((qap + temp) * (alpha2 + temp))
app = ap + d * az
bpp = bp + d * bz
aold = az
am = ap / bpp
bm = bp / bpp
az = app / bpp
bz = 1
If Abs(az - aold) < errorf * Abs(az) Then
GoTo FinalStep
End If
Next m
ErrorStep:
'Error = MsgBox("Either alpha or beta is too big or the maximum iterations are too small for convergence", vbOKOnly, "Problem in RMSBetaCF function")
RMSBetaCF = 1
GoTo Abend
FinalStep:
RMSBetaCF = az
Abend:
'Msg = MsgBox(m & " iterations ", vbOKOnly)
End Function
Any help with this would be greatly appreciated!
Thanks,
Guytz72
|
|
|
|
|
hi,
just start reading some c# tutorials - you'll be able to convert it very soon but dont expect anyone in here to do the work for you ;D there are several free ebooks available and you also have access to a lot of articles here on codeproject.
Good luck,
mik
|
|
|
|
|
Thanks Mik, Am doing a C# course at the moment...not so much the C# that is the problem, more the Maths and VBA and knowing where to start!
Cheers,
Guytz
|
|
|
|
|
|