Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 09-11-2004, 09:58 PM   #1 (permalink)
 
Junior Techie

Join Date: Sep 2002

Posts: 70

Mewgen1 is on a distinguished road

Question Newbie VB Problems

Hi all. First I would like to apologize for what I am sure will turn into the first of many questions about this language that have very simple answers. I am currently taking a Visual Basic course in college and we just got our first homework assignment. I built the interface and then started inputting code for a command button. ItÂ’s intended to take the name of a Baseball team, their number of wins and their number of losses then, when the cmd button is clicked; itÂ’s supposed to put a statement in a picture box that tells the teams percentage of wins. Unfortunately, once thought that I was finished and executed it, it gave me a message that says "Method or Data member not found"


So my questions are:

1. What did I do wrong in my code?

2. What exactly does this error mean?

IÂ’m using VB6 working model edition which apparently doesnÂ’t come with any help files. Please feel free to point out any other potential problems that I might be having.

Since I canÂ’t attach the form file I'll just post the code here.

<code>
Private Sub cmdCompute_Click()

Dim Team As String
Dim Won As Integer
Dim Lost As Integer
Dim Total As Integer

Team = txtTeam.Text
Won = Val(txtWon.Text)
Lost = Val(txtLost.Text)
Total = Won + Lost

picPercent.Cls
picPercent.Print Team & "won"; Total / Won & "percent of its games."


End Sub
</code>
__________________
Windows XP Proffesional SP2
Pentium 4b CPU 2.66GHz
-533 Mhz FSB
Biostar U8598 (downscaled) >.<
-VIA P4X400-8235 Chipset
-Phoenix - AwardBIOS v6.00PG
1024MB DDR400 RAM (single stick)
BFG NVIDIA GeForce 6800GT OC
-256.0 MB VRAM
-Forceware 84.21
-DirectX 9.0d
SB Audigy 2 ZS
Mewgen1 is offline  
Old 09-12-2004, 09:32 AM   #2 (permalink)
 
Banned

Join Date: May 2003

Posts: 105

imported_Jack

Default

It looks like the problem is that the cls and print methods do not exist for the picPercent object.

You can go to the object prowser (F2) and see what the properties and methods for your picPercent are and fix it accordingly.
imported_Jack is offline  
Old 09-12-2004, 04:45 PM   #3 (permalink)
 
Junior Techie

Join Date: Sep 2002

Posts: 70

Mewgen1 is on a distinguished road

Default

Thanks for the suggestion Jack. Unfourtunatley that doesnt appear to be the problem. It seems to be a problem with getting the information from the text boxes (txtTeam, txtWon, and txtLost) When I type in:

<code>Won = Val(txtWon.text)</code>

it generates the previously stated error. If I change the .text part to somethign else like .count it runs athourhg and prints the output just fine. Of course it seems to think that the contents of the txtWon is 1 no matter what I put into the box.

So I guess my question has become: How do I get the contents of the txtBoxes into the variables that I need them in?
__________________
Windows XP Proffesional SP2
Pentium 4b CPU 2.66GHz
-533 Mhz FSB
Biostar U8598 (downscaled) >.<
-VIA P4X400-8235 Chipset
-Phoenix - AwardBIOS v6.00PG
1024MB DDR400 RAM (single stick)
BFG NVIDIA GeForce 6800GT OC
-256.0 MB VRAM
-Forceware 84.21
-DirectX 9.0d
SB Audigy 2 ZS
Mewgen1 is offline  
Old 09-12-2004, 05:08 PM   #4 (permalink)
 
Super Techie

Join Date: Jul 2004

Posts: 398

kostas

Default

are txtWon and txtLost strings or text objects? check their definitions

also, help me out with a word here:

Quote:
athourhg
what does that mean?
kostas is offline  
Old 09-13-2004, 11:23 PM   #5 (permalink)
 
Super Techie

Join Date: Jun 2004

Posts: 312

sippin codeine

Send a message via Yahoo to sippin codeine
Default

Hello, i think your syntax is incorrect.
Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Team As String
        Dim Won As Integer
        Dim Lost As Integer
        Dim Total As Integer

        Team = TextBox1.Text
        Won = Val(TextBox2.Text)
        Lost = Val(TextBox3.Text)
        Total = Val(Won + Lost)
        MsgBox(Team & " won " & Total & " percent of its games.")
    End Sub
End Class
Generates this, maybe what your looking for.



I cannot get a picturebox to display text so i used a msgbox.
__________________
**[System specs]**

Delphi Enterprise 6 - 7
VB 6.0 - 2005 EE
sippin codeine is offline  
Old 09-14-2004, 06:02 PM   #6 (permalink)
 
Junior Techie

Join Date: Sep 2002

Posts: 70

Mewgen1 is on a distinguished road

Default

Quote:
Originally posted by kostas
are txtWon and txtLost strings or text objects? check their definitions

also, help me out with a word here:



what does that mean?
Hmm, i think this is simply a result of my posting at 1 AM in the morning after spending 8 hours at work.

As I understand it txt boxes always output a string, which must then be converted into integers or some other form of number. Please correct me if im wrong on this, however, I can only know what I've read in the book or been told by the teacher. Or what i learn from the people on this board.

Sippin:
I dont know what I could have done wrong in my syntax. After I spent more time on this than was reasonable I scrapped th file and started again from scratch. I dont know exactlly why, but after I started fresh the program ran fine the first time i tried it. I think my original problem had something to do with a message that I got asking if I wanted to place the txtboxes into arrays, or somethign to that effect. Anyways now its working just fine and Im having fun addign IF-THEN statements to insult the teams

Oh, while Im thinking about it: Sippin, whats that theme you have on your computer and are there more like it?
__________________
Windows XP Proffesional SP2
Pentium 4b CPU 2.66GHz
-533 Mhz FSB
Biostar U8598 (downscaled) >.<
-VIA P4X400-8235 Chipset
-Phoenix - AwardBIOS v6.00PG
1024MB DDR400 RAM (single stick)
BFG NVIDIA GeForce 6800GT OC
-256.0 MB VRAM
-Forceware 84.21
-DirectX 9.0d
SB Audigy 2 ZS
Mewgen1 is offline  
Old 09-26-2004, 05:56 AM   #7 (permalink)
 
Newb Techie

Join Date: Sep 2004

Posts: 17

HackingMachine

Send a message via AIM to HackingMachine
Default

HackingMachine: Please don't post unless it's helpful and relevant. Thanks - Emily
HackingMachine is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On