Click here to Skip to main content
15,905,558 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Private Sub Command1_Click()
Dim a, b, c As Integer
a = Text1.Text
b = Text2.Text
c = Text3.Text
If a = b Then
    If a = c Then
        MsgBox "type of triangle is equilateral"
        MsgBox "type of triangle is isoceles"
    End If
ElseIf a = c Then
    MsgBox "Type of triangle is isoceles"
ElseIf b = c Then
    MsgBox "Type of triangle is isoceles"
    MsgBox "Type of triangle is oblique"
End If
End Sub

What I have tried:

when I run program this eror occur "method or data member not found"
Updated 5-Feb-18 2:11am
CPallini 5-Feb-18 6:33am    
Please report the exact error message (which is more informative than the info you provided).
CodeWraith 5-Feb-18 7:10am    
Bonus points for looking into the stack trace to find the line which throws this error.
pt1401 5-Feb-18 7:27am    
Have you tried debugging and stepping through your program?
Which line does it error on? Which method or data member couldn't be found?

The only way you can get that error with the code snippet you have shared is if Text1, Text2 or Text3 do not have a Text property. It is unclear what controls those are meant to be as they are not the default names

There are other problems with your code:

1. Use sensible names for buttons and textboxes. You might be able to remember just now that Command1 tells you what type of triangle you have described, but when you come back to the code in 6 months time, after you've added functionality - will you still remember? Get into good habits as soon as possible.

2. I think that you think you have defined 3 integers with
Dim a, b, c As Integer
but you are probably going to find that a and b are Variants. Try explicitly declaring your variables e.g.
Dim a As Integer, b As Integer, c As Integer

3. I'm not a fan of single letter variables either - try to be more descriptive

4. Consider the line
c = Text3.Text
You're going to get a "Type Mismatch" error on that line because Text1.Text is ... er ... text, a string and c is an integer. Some compilers let you get away with it and make an implicit conversion for you but if you leave the textbox blank the compiler cannot cope. Make sure any change of type is obvious and your code will be more robust and portable e.g.
c = Val(Sheet1.Text3.Text)

After addressing all of the above there is nothing actually "wrong" with the code you have presented, but note I used the word "portable" above? If you can drop the use of VB6 then you should drop it and use VB.NET (or C# if you prefer). VB6 hasn't been suppported by Microsoft in decades. If your school insists on you using VB6 then leave and spend your money elsewhere.

Finally, try to use more meaningful titles for your questions - mostly everyone who posts in QA is looking for help :-) Avoid using "txt-speak" (plz) if you want to be taken seriously
Share this answer
CPallini 5-Feb-18 8:34am    
You are declaring your variables as Integer but assign strings. As far as I remember, VB6 does not support implicit conversions for strings to numeric types. You have to convert the strings to integers first using the CInt() function:
a = CInt(Text1.Text)
b = CInt(Text2.Text)
c = CInt(Text3.Text)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900