•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 391,897 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,555 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser:
Views: 3137 | Replies: 2
![]() |
•
•
Join Date: Feb 2006
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
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!)
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!)
•
•
Join Date: Mar 2006
Location: Texas
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Start by looking at the definition of the three types of triangles:
If intSide1 = intSide2 And intSide2 = intSide3 Then
intSide2 = intSide3 Then
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.
Equilateral means all three sides are equal
Isosceles means two sides are equal
Scalene means all three are differentUse 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.
Kevin Jordan
scratchProjects.com :: Programming the world from scratch
scratchProjects.com :: Programming the world from scratch
•
•
Join Date: Feb 2006
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Originally Posted by jacjr
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!)
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
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
- VC++ .net Build problem (C++)
- downloading from the net is incomplete! (Web Browsers)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
- ASP.NET - session objects Problem (ASP.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Regarding VB.net
- Next Thread: Ms Vb 2005


Linear Mode