Hello to everyone! I have just started taking what is described as a beginning Visual Basic.Net class. I have no programming knowledge, except my class time which started mid January.
Right now I'm trying to figure out how to give a type of triangle(equilateral, scalene, or isosceles) and the shortest side of the triangle. We have been talking about relational, logical operators, If, Else statements.

I am thoroughly conflabbergasted at this point. Our text we are using, "Microsoft Visual Basic .Net Programming: problem analysis to design" , by E. Reed Doak, doesn't really seem to be beginner friendly. Am looking for suggestions on other text for BEGINNERS!

Here is the code I've managed in about3 hours work on this problem:

Module TriangleTypes
Sub Main()
:o
'
' Declare variables
Dim strTriangle As String
Dim intSide1, intSide2, intSide3 As Integer
'
' Ask for user Input
'
Console.Write("Enter length of side 1 of a triangle as an integer: ")
intSide1 = Convert.ToInt32(Console.ReadLine())
Console.WriteLine()
Console.Write("Enter length of side 2 of a triangle as an integer: ")
intSide2 = Convert.ToInt32(Console.ReadLine())
Console.WriteLine()
Console.Write("Enter length of side 3 of a triangle as an integer: ")
intSide3 = Convert.ToInt32(Console.ReadLine())
Console.WriteLine()
'
If intSide1 = intSide2 Then
strTriangle = "Equilateral"
Else
If intSide1 = intSide3 Then
strTriangle = "Equilateral"
Else
If intSide2 = intSide3 Then
strTriangle = "Equilateral"
Else
If intSide1 <> intSide2 Then



End If


End If
End If


Console.WriteLine("Your triangle type is: {0}", strTriangle)

ANY Help would be appreciated.
thanks,
jacjr (back to school at 40!)

Start by looking at the definition of the three types of triangles:
Equilateral means all three sides are equal
Isosceles means two sides are equal
Scalene means all three are different
Use the if statements to test for that logic

If intSide1 = intSide2 And intSide2 = intSide3 Then
strTriangle = "Equilateral"
Else If intSide1 = intSide2 Or intSide1 = intSide3 Or _
intSide2 = intSide3 Then
strTriangle = "Isosceles"
Else
strTriangle = "Scalene"
End If

I didn't have a chance to through this in Visual Studio, but the logic is right. The book we used in school and I really liked was called Visual Basic.NET How To Program. I had a friend who used the C# version too, and he said it was pretty good. Let me know if you need any more help.

Figured it out thanks for the help:

Dim strTriangle As String
Dim intSide1, intSide2, intSide3 As Integer
Dim intShortSide As Integer
'
' Ask for user Input
'
Console.Write("Enter length of side 1 of a triangle as an integer: ")
intSide1 = Convert.ToInt32(Console.ReadLine())
Console.WriteLine()
Console.Write("Enter length of side 2 of a triangle as an integer: ")
intSide2 = Convert.ToInt32(Console.ReadLine())
Console.WriteLine()
Console.Write("Enter length of side 3 of a triangle as an integer: ")
intSide3 = Convert.ToInt32(Console.ReadLine())
Console.WriteLine()
'
' find type of triangle
If intSide1 = intSide2 And intSide2 = intSide3 Then
strTriangle = "Equilateral"
Console.WriteLine("Your triangle type is: {0}", strTriangle)
Console.WriteLine()
Else
If intSide1 = intSide2 Or intSide3 = intSide2 Or intSide1 = intSide3 Then
strTriangle = "Isosceles"
Console.WriteLine("Your triangle type is: {0}", strTriangle)
Console.WriteLine()
Else
If intSide1 <> intSide2 And intSide1 <> intSide3 And intSide2 <> intSide3 Then
strTriangle = "Scalene"
Console.WriteLine("Your triangle type is: {0}", strTriangle)
'
' give shortest side
If intSide1 < intSide2 Then
intShortSide = intSide1
Else
intShortSide = intSide2
End If
If intSide3 < intShortSide Then
intShortSide = intSide3
End If
End If
End If
End If
Console.WriteLine()
Console.WriteLine("The shortest side has a length of {0}. ", intShortSide)
Console.WriteLine()


End Sub


End Module
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.