Hi Scott Mitchell,

Jiggiedoez

New Member
Can you give me the equivalent VB.NET code for the following c# lines?<BR><BR>objGraphics.FillRectangle((SolidBrush) colors[iLoop], 5, <BR> height - legendHeight + <BR>fontLegend.Height * iLoop + 5, 10, 10);<BR><BR>objGraphics.DrawString(((String) ds.Tables[0].Rows[iLoop][labelColumnName]) + " - " + <BR>Convert.ToString(ds.Tables[0].Rows[iLoop][dataColumnName]), fontLegend, blackBrush, 20, height - legendHeight + fontLegend.Height * iLoop + 1);<BR><BR>These lines were taken from your website at<BR>http://msdn.microsoft.com/msdnmag/issues/02/02/ASPDraw/ASPDraw.asp<BR><BR><BR>Actually I am asked to draw Pie Chart by getting its data from the database which is similar to what you have done.But I prefer VB than c#.<BR>So can you kindly help me out with this<BR>thx <BR>PhilipJust replace the [ and ] with ( and ), and get rid of the semicolons at the end of statements. (C# index arrays as arrayName[index] whereas VB.NET uses parenthesis as arrayName(index).)<BR><BR>hthThis is how I changed:<BR><BR>for iLoop = 0 to ds.Tables(0).Rows.Count-1<BR> objGraphics.FillPie((SolidBrush)colors(iLoop), pieRect, currentDegree, Convert.ToSingle(ds.Tables(0).Rows(iLoop)(dataColu mnName)) / total * 360)<BR><BR>' increment the currentDegree<BR>currentDegree += Convert.ToSingle(ds.Tables(0).Rows(iLoop) (dataColumnName)) / total * 360<BR><BR>Next<BR><BR>But the error is :<BR>Compiler Error Message: BC30684: The name 'SolidBrush' is declared as a type, and so cannot be used as an expression.<BR><BR>This is the line that error exists:<BR>objGraphics.FillPie((SolidBrush)colors(iLoop), pieRect, currentDegree,Convert.ToSingle(ds.Tables(0).Rows(i Loop)(dataColumnName)) / total * 360)<BR>Yeah, you're going to have errors there. This is casting, and is a c# thing that you don't need to do in VB.NET. Essentially remove that (SolidBrush) thingie. Also, realize that VB.NET uses & for string concatenation, while C# uses +. So where you see + or += you'll need to change to & and &=, respectively.<BR><BR>hthThank You Scott.
 
Back
Top