who can help me to derive this C++ codes to VB that can draw the triangle

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>

main()
{
 clrscr();
 float a,b,c,S,D,A,B,C,Area,R;
 printf("Enter the lengths of the three sides of the triangle :

");
 scanf("%f%f%f",&a,&b,&c);

 S = (a+b+c)/2.0;        // S is the semiperimeter of the triangle
 D = S*(S-a)*(S-b)*(S-c);//D is the square of the area of the triangle
 if(D<=0)
 {
  printf("
The triangle cannot be formed");
  getch();
  exit(0);
 }

 if((a==b || b==c || c==a) && !(a==b && b==c && c==a))
// this complex logic is to eliminate interpretting a triangle with all
three
// sides equal as both isosceles and equilateral.
   printf("
The triangle is ISOSCELES

");
 if(a==b && b==c && c==a)
   printf("
The triangle is EQUILATERAL

");
 if(a!=b && b!=c && c!=a)
  printf("
The triangle is SCALENE

");

 Area = sqrt(D);
 R = (a*b*c)/(4.0*Area);
 printf("PERIMETER     = %.2f units
",(2.0*S));
 printf("AREA          = %.2f sq.units
",Area);
 printf("CIRCUM RADIUS = %.2f units
",R);
// using sine rule,we get...
 A = (180.0/3.1415926)*asin(a/(2.0*R));//  value of pi should be upto 7
 B = (180.0/3.1415926)*asin(b/(2.0*R));//  decimal places of accuracy and
also
 C = (180.0/3.1415926)*asin(c/(2.0*R));//  note that the 7th decimal place
is
		 		 		 		        //  6 and not 7 as it had to be if were
 if(A==90.0 || B==90.0 || C==90.0)     //  approximated to 7 decimal
places
  printf("
The triangle is RIGHT ANGLED
");
 if(A<90.0 && B<90.0 && C<90.0)
  printf("
The triangle is ACUTE ANGLED
");
 if(A>90.0 || B>90.0 || C>90.0)
  printf("
The triangle is OBTUSE ANGLED
");

 printf("
The angles are as follows :

");
 printf("A = %.2f degrees
",A);
 printf("B = %.2f degrees
",B);
 printf("C = %.2f degrees
",C);
 printf("
Where A,B,C stand for angles opposite to sides
%.2f,%.2f,%.2f",a,b,c);
 printf(" respectively
");


 getch();
 return 0;
}

That's not c++. That's c.

You declare floats as double or single in VB, int as long or integer.

I would use text boxes for user input. And then I would suggest using code in a command button click event to draw the lines of your triangle.

You don't have to add any special math headers as in C, just use the cos, sin, tan, etc functions: they are already loaded.


All the logic shown in this simple c program can be performed using:

if ( ... conditional statements) then
' statements
else
' statements
EndIf


[object.]Line [(x1, y1)]–(x2, y2)[, color]
Will draw the lines of the triangle.

You can use the msgbox function to replace your printf functions. And you might use text input boxes to replace the use of the scanf function in C.

VB8:
Imports System

Private Shared Function Main() As Integer
clrscr()
Dim a As Single
Dim b As Single
Dim c As Single
Dim S As Single
Dim D As Single
Dim A As Single
Dim B As Single
Dim C As Single
Dim Area As Single
Dim R As Single
Console.Write("Enter the lengths of the three sides of the triangle : ")
scanf("%f%f%f", a, b, c)

S = (a+b+c)/2.0 ' S is the semiperimeter of the triangle
D = S*(S-a)*(S-b)*(S-c) 'D is the square of the area of the triangle
If D<=0 Then
Console.Write(" The triangle cannot be formed")
Console.ReadKey(True).KeyChar
exit(0)
End If

If (a =b OrElse b =c OrElse c =a) AndAlso Not(a =b AndAlso b =c AndAlso c =a) Then
' this complex logic is to eliminate interpretting a triangle with all
' sides equal as both isosceles and equilateral.
Dim printf As three = New three(" The triangle is ISOSCELES ")
End If
If a =b AndAlso b =c AndAlso c =a Then
Console.Write(" The triangle is EQUILATERAL ")
End If
If a<>b AndAlso b<>c AndAlso c<>a Then
Console.Write(" The triangle is SCALENE ")
End If

Area = Math.Sqrt(D)
R = (a *b *c)/(4.0 *Area)
Console.Write("PERIMETER = {0:f2} units ",(2.0 *S))
Console.Write("AREA = {0:f2} sq.units ",Area)
Console.Write("CIRCUM RADIUS = {0:f2} units ",R)
' using sine rule,we get...
A = (180.0/3.1415926)*Math.Asin(a/(2.0 *R)) ' value of pi should be upto 7
B = (180.0/3.1415926)*Math.Asin(b/(2.0 *R)) ' decimal places of accuracy and
Dim C As also = (180.0/3.1415926)*Math.Asin(c/(2.0 *R)) ' note that the 7th decimal place
is
' 6 and not 7 as it had to be if were
If A =90.0 OrElse B =90.0 OrElse C =90.0 Then ' approximated to 7 decimal
Dim printf As places = New places(" The triangle is RIGHT ANGLED ")
End If
If A<90.0 AndAlso B<90.0 AndAlso C<90.0 Then
Console.Write(" The triangle is ACUTE ANGLED ")
End If
If A>90.0 OrElse B>90.0 OrElse C>90.0 Then
Console.Write(" The triangle is OBTUSE ANGLED ")
End If

Console.Write(" The angles are as follows : ")
Console.Write("A = {0:f2} degrees ",A)
Console.Write("B = {0:f2} degrees ",B)
Console.Write("C = {0:f2} degrees ",C)
Console.Write(" Where A,B,C stand for angles opposite to sides {0:f2},{1:f2},{2:f2}",a,b,c)
Console.Write(" respectively ")


Console.ReadKey(True).KeyChar
Return 0
End Function
Private Shared Function Main() As Integer
clrscr()
Dim a As Single
Dim b As Single
Dim c As Single
Dim S As Single
Dim D As Single
Dim A As Single
Dim B As Single
Dim C As Single
Dim Area As Single
Dim R As Single
Console.Write("Enter the lengths of the three sides of the triangle : ")
scanf("%f%f%f", a, b, c)

S = (a+b+c)/2.0 ' S is the semiperimeter of the triangle
D = S*(S-a)*(S-b)*(S-c) 'D is the square of the area of the triangle
If D<=0 Then
Console.Write(" The triangle cannot be formed")
Console.ReadKey(True).KeyChar
exit(0)
End If

If (a =b OrElse b =c OrElse c =a) AndAlso Not(a =b AndAlso b =c AndAlso c =a) Then
' this complex logic is to eliminate interpretting a triangle with all
' sides equal as both isosceles and equilateral.
Dim printf As three = New three(" The triangle is ISOSCELES ")
End If
If a =b AndAlso b =c AndAlso c =a Then
Console.Write(" The triangle is EQUILATERAL ")
End If
If a<>b AndAlso b<>c AndAlso c<>a Then
Console.Write(" The triangle is SCALENE ")
End If

Area = Math.Sqrt(D)
R = (a *b *c)/(4.0 *Area)
Console.Write("PERIMETER = {0:f2} units ",(2.0 *S))
Console.Write("AREA = {0:f2} sq.units ",Area)
Console.Write("CIRCUM RADIUS = {0:f2} units ",R)
' using sine rule,we get...
A = (180.0/3.1415926)*Math.Asin(a/(2.0 *R)) ' value of pi should be upto 7
B = (180.0/3.1415926)*Math.Asin(b/(2.0 *R)) ' decimal places of accuracy and
Dim C As also = (180.0/3.1415926)*Math.Asin(c/(2.0 *R)) ' note that the 7th decimal place
is
' 6 and not 7 as it had to be if were
If A =90.0 OrElse B =90.0 OrElse C =90.0 Then ' approximated to 7 decimal
Dim printf As places = New places(" The triangle is RIGHT ANGLED ")
End If
If A<90.0 AndAlso B<90.0 AndAlso C<90.0 Then
Console.Write(" The triangle is ACUTE ANGLED ")
End If
If A>90.0 OrElse B>90.0 OrElse C>90.0 Then
Console.Write(" The triangle is OBTUSE ANGLED ")
End If

Console.Write(" The angles are as follows : ")
Console.Write("A = {0:f2} degrees ",A)
Console.Write("B = {0:f2} degrees ",B)
Console.Write("C = {0:f2} degrees ",C)
Console.Write(" Where A,B,C stand for angles opposite to sides {0:f2},{1:f2},{2:f2}",a,b,c)
Console.Write(" respectively ")


Console.ReadKey(True).KeyChar
Return 0
End Function

tnx for diz but how bout d drawing


im sorry that was c not c++ (lol)

who can encode this to a vb den attach to ur post tnx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.