Click here to Skip to main content
15,890,670 members
Home / Discussions / C#
   

C#

 
GeneralAccessing multiple Excel files Pin
janigorse7-Aug-04 19:03
janigorse7-Aug-04 19:03 
GeneralHelp with c# Pin
Tom Dziedzic7-Aug-04 16:49
Tom Dziedzic7-Aug-04 16:49 
GeneralRe: Help with c# Pin
Tom Dziedzic7-Aug-04 17:12
Tom Dziedzic7-Aug-04 17:12 
GeneralRe: Help with c# Pin
Tom Dziedzic7-Aug-04 17:19
Tom Dziedzic7-Aug-04 17:19 
GeneralRe: Help with c# Pin
Paul Lyons7-Aug-04 17:40
Paul Lyons7-Aug-04 17:40 
GeneralRe: Help with c# Pin
Tom Dziedzic7-Aug-04 17:44
Tom Dziedzic7-Aug-04 17:44 
GeneralRe: Help with c# Pin
Tom Dziedzic7-Aug-04 17:54
Tom Dziedzic7-Aug-04 17:54 
GeneralRe: Help with c# Pin
DougW487-Aug-04 19:36
DougW487-Aug-04 19:36 
just use a cast...

UInt32 A = 0;<br />
UInt32 O = 0;<br />
A = Convert.ToUInt32(tbA.Text);<br />
O = Convert.ToUInt32(tbO.Text);<br />
tbResults.Text = (string)(A/O);<br />
tbResults.Text = (string)(Math.Pow(A, 2)/Math.Sqrt(O));


if these inputs are coming from a textbox, which it looks like they are, you should consider putting a try/catch block around those Convert statements to make sure the input is valid:

UInt32 A = 0;<br />
UInt32 O = 0;<br />
try<br />
{<br />
A = Convert.ToUInt32(tbA.Text);<br />
}<br />
catch<br />
{<br />
tbA.Text = "0";<br />
A = 0;<br />
}<br />
try<br />
{<br />
O = Convert.ToUInt32(tbO.Text);<br />
}<br />
catch<br />
{<br />
tbO.Text = "0";<br />
O = 0;<br />
}<br />
tbResults.Text = A/O;<br />
tbResults.Text = Math.Pow(A, 2)/Math.Sqrt(O); 


I have always used Parse, such as UInt32.Parse(string); instead of Convert, so I'm not sure if it will handle incorrect strings or not, but this is good just to make sure. Obviously you don't have to use 0 to assign to A and O in the try/catch blocks, you can make them whatever you want. Good luck!
GeneralRe: Help with c# Pin
leppie7-Aug-04 23:37
leppie7-Aug-04 23:37 
GeneralRe: Help with c# Pin
DougW488-Aug-04 6:52
DougW488-Aug-04 6:52 
GeneralRe: Help with c# Pin
Tom Dziedzic8-Aug-04 6:02
Tom Dziedzic8-Aug-04 6:02 
GeneralRe: Help with c# Pin
Tom Dziedzic8-Aug-04 6:31
Tom Dziedzic8-Aug-04 6:31 
GeneralInvalidCastException with CAPICOM and webServices Pin
Escroto7-Aug-04 12:50
Escroto7-Aug-04 12:50 
GeneralRe: InvalidCastException with CAPICOM and webServices Pin
Alex Korchemniy7-Aug-04 13:09
Alex Korchemniy7-Aug-04 13:09 
GeneralRe: InvalidCastException with CAPICOM and webServices Pin
beowulfagate7-Aug-04 16:55
beowulfagate7-Aug-04 16:55 
GeneralReplace Task Manager Pin
mrtaikandi7-Aug-04 2:08
professionalmrtaikandi7-Aug-04 2:08 
GeneralRe: Replace Task Manager Pin
Alex Korchemniy7-Aug-04 13:04
Alex Korchemniy7-Aug-04 13:04 
GeneralExecuting an external application Pin
mrtaikandi7-Aug-04 2:00
professionalmrtaikandi7-Aug-04 2:00 
GeneralRe: Executing an external application Pin
Alex Korchemniy7-Aug-04 12:59
Alex Korchemniy7-Aug-04 12:59 
GeneralUrgent - Need help inserting line into text file. Pin
IrishSonic7-Aug-04 1:30
IrishSonic7-Aug-04 1:30 
GeneralRe: Urgent - Need help inserting line into text file. Pin
DavidR_r7-Aug-04 2:00
DavidR_r7-Aug-04 2:00 
GeneralRe: Urgent - Need help inserting line into text file. Pin
leppie7-Aug-04 2:32
leppie7-Aug-04 2:32 
GeneralRe: Urgent - Need help inserting line into text file. Pin
IrishSonic7-Aug-04 6:46
IrishSonic7-Aug-04 6:46 
GeneralRe: Urgent - Need help inserting line into text file. Pin
Sue92abc23-Oct-04 8:26
Sue92abc23-Oct-04 8:26 
GeneralSimple Math on a datagrid Pin
christopher_seewald6-Aug-04 23:18
christopher_seewald6-Aug-04 23:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.