Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Can anyone help a beginner student?


Reply
 
Thread Tools Display Modes
  #1  
Old 03-11-2003, 04:04 PM
twirlerzmom twirlerzmom is offline
Freshman
 
Join Date: Mar 2003
Posts: 25
Unhappy Can anyone help a beginner student?


I am a beginner VB 6.0 student who was doing great until the textbook suddenly forgot we were beginners and left the explanations and examples by the wayside. My problem is this (well I have lots, but let's start with the simple ones first). I need to write statements to store the value 0 (zero) in each of the text boxes when the form loads. My form has a total of 13 textboxes, one holding a name, and the rest holding the quantity of different size lumber that is ordered. 12 of these boxes are in arrays (4 boxes in 3 different frames). I used this code to clear the boxes:

Private Sub Form_Load()

txt2x4x8.Caption = "0"
txt2x4x10.Caption = "0"
txt2x4x12.Caption = "0"
txt2x4x14.Caption = "0"
txt2x6x8.Caption = "0"
txt2x6x10.Caption = "0"
txt2x6x12.Caption = "0"
txt2x6x14.Caption = "0"
txt2x8x8.Caption = "0"
txt2x8x10.Caption = "0"
txt2x8x12.Caption = "0"
txt2x8x14.Caption = "0"

But I get this error message:

Compile Error:
Method or Data member not found

I know there must be an easier way to do this but I haven't figured it out and I don't understand why I'm getting this error, much less fix it so I can't even run my program to see how far I get in it.

Does anyone have any advice? Also, I'm one who likes to understand the "whys" I'm doing something, could you explain the reasoning behind any advice given? That seems to help me understand the steps in VB better than just saying "do this". Thanks so much.
Reply With Quote
  #2  
Old 03-11-2003, 04:06 PM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,885
Default

You get this error on which line?
Do all these textboxes actually exists on the form?
Reply With Quote
  #3  
Old 03-11-2003, 04:06 PM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,885
Default

A textbox doesn't have a .Caption property, you want to .Text property
Reply With Quote
  #4  
Old 03-11-2003, 04:29 PM
twirlerzmom twirlerzmom is offline
Freshman
 
Join Date: Mar 2003
Posts: 25
Default

[QUOTE='Flyguy']You get this error on which line?
Do all these textboxes actually exists on the form?[/QUOTe

1. The error highlights "Private Sub Form _Load and the word "caption" on the very first textbox.

2. Yes, they all exist. I tried all sorts of different ways to word it but I still get the same error.
Reply With Quote
  #5  
Old 03-11-2003, 04:31 PM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,885
Default

Read my second reply again.
Quote:
Originally Posted by Flyguy
A textbox doesn't have a .Caption property, you want to .Text property
Reply With Quote
  #6  
Old 03-11-2003, 04:33 PM
twirlerzmom twirlerzmom is offline
Freshman
 
Join Date: Mar 2003
Posts: 25
Default

Quote:
Originally Posted by Flyguy
A textbox doesn't have a .Caption property, you want to .Text property
Ok, I tried that previously and then get this error:

Compile Error:

Invalid outside procedure

and then highlights "0" in the general declarations.
Reply With Quote
  #7  
Old 03-11-2003, 04:38 PM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,885
Default

Can you post more of your code?
Reply With Quote
  #8  
Old 03-11-2003, 06:17 PM
Steo Steo is offline
Freshman
 
Join Date: Oct 2002
Location: Ireland
Posts: 40
Default

Try removing the quotes from the numbers
__________________
Nork
Reply With Quote
  #9  
Old 03-11-2003, 06:24 PM
twirlerzmom twirlerzmom is offline
Freshman
 
Join Date: Mar 2003
Posts: 25
Default

Here is the background of what I am trying to do:

Write a program that determines the total feet and total cost for each type of lumber (2x4,2x6,2x8) in 8,10,12, 14 foot lengths. Completed form should be divided into 2 parts, input and output using 2 shapes. Input has a label for customer's name and corresponding text box. Create 3 checkboxes for the different types of lumber, and a check box for each length in each type. Use a control array for each procedure length. Each checkbox has a corresponding text box in which to specify quantity desired, also done as arrays. Then there are 4 delivery areas, Areas 1, 2, 3, 4. Calculate the delivery charges based on number of feet delivered and the delivery zone.
1-499 feet=$10
500-999feet=$20
1000-2000=$30
>200 feet=$40

Output section:need labels to hold number of feet of each product and the total cost. Another label to hold the delivery total and order total.
Lumber Prices:
2x4=.16 foot
2x6=.22 foot
2x8=.31 foot
Use Constants for these values.
Need 3 command buttons:total order based on input, clear the input and output in preparation for a new order, and exit command.

I know it sounds like a lot, and much more than you probably needed to know but I thought I might as well write it all down. I don't have much code written as I am doing this in steps according to my textbook. So I'm just concerned with my original problem I posted. I know I probably have much more than just that wrong, but until I get past this problem, and can run my program, I won't be able to see where my other problems are. So the code I wrote was basically the calculations, and I'm working on clearing the input for the NewOrder command, and setting those darn textboxes to 0. Please don't think I'm looking for someone to "give" me the answers, it's not like that at all. I'm just looking for someone who might be able to help "tutor" and explain along the way to a beginner student. I should mention that I am doing my entire degree online, so that traditional instructor/student rapport is missing and it gets hard when you are stuck and don't have many resources available for help. These forums are a great help and a wealth of information for people like me. I'm so glad I stumbled across it. Just reading other's posts has helped me to correct a few things already. Thanks!



Option Explicit
Dim pstrDeliveryCharge As Currency
Dim pstrFeetCharge As Currency
Public pintTotalFeet As Integer
Private Const csng2x4Price As Single = 0.16
Private Const csng2x6Price As Single = 0.22
Private Const csng2x8Price As Single = 0.31

txt2x4x8.Text = "0"

Dim mintIndex2x4Length As Integer
Dim mintIndex2x6Length As Integer
Dim mintIndex2x8Length As Integer
Dim mintIndexDelivery As Integer


Private Sub cmdNewOrder_Click()
txtName.Text = vbNullString
chk2x4.Value = vbUnchecked
chk2x6.Value = vbUnchecked
chk2x8.Value = vbUnchecked
chk2x4Lengths(mintIndex2x4Length).Value = False
mintIndex2x4Length = -1
chk2x6Lengths(mintIndex2x6Length).Value = False
mintIndex2x6Length = -1
chk2x8Lengths(mintIndex2x8Length).Value = False
mintIndex2x8Length = -1
txt2x4x8.Text = vbNullString
txt2x4x8.Text = "0"
txt2x4x10.Text = vbNullString
txt2x4x10.Text = "0"
txt2x4x12.Text = vbNullString
txt2x4x12.Text = "0"
txt2x4x14.Text = vbNullString
txt2x4x14.Text = "0"
txt2x6x8.Text = vbNullString
txt2x6x8.Text = "0"
txt2x6x10.Text = vbNullString
txt2x6x10.Text = "0"
txt2x6x12.Text = vbNullString
txt2x6x12.Text = "0"
txt2x6x14.Text = vbNullString
txt2x6x14.Text = "0"
txt2x8x8.Text = vbNullString
txt2x8x8.Text = "0"
txt2x8x10.Text = vbNullString
txt2x8x10.Text = "0"
txt2x8x12.Text = vbNullString
txt2x8x12.Text = "0"
txt2x8x14.Text = vbNullString
txt2x8x14.Text = "0"
OptDelivery(mintIndexDelivery).Value = False
mintIndexDelivery = -1
lbl2x4TotalFeet.Caption = ""
lbl2x6TotalFeet.Caption = ""
lbl2x8TotalFeet.Caption = ""
lbl2x4Cost.Caption = ""
lbl2x6Cost.Caption = ""
lbl2x8Cost.Caption = ""
lblDeliveryCost.Caption = ""
lblTotalOrderCost.Caption = ""
Reply With Quote
  #10  
Old 03-11-2003, 06:27 PM
Deadalus Deadalus is offline
Promising Talent

Retired Moderator
* Guru *
 
Join Date: May 2002
Location: Brussels
Posts: 3,601
Default

Quote:
Originally Posted by twirlerzmom
Ok, I tried that previously and then get this error:

Compile Error:

Invalid outside procedure

and then highlights "0" in the general declarations.
Why would you have it in the Declarations section? In the Load sub like you had it seems fine. you can't assign a value to a variable in the Declarations section.
Reply With Quote
  #11  
Old 03-11-2003, 06:33 PM
twirlerzmom twirlerzmom is offline
Freshman
 
Join Date: Mar 2003
Posts: 25
Default

I thought of that after really looking at it. So I tried taking out the value and I still get the same error. I just not declaring it, and then I get "member not found". I've probably really screwed my code up now by just cutting and pasting whatever I thought could be the problem and trying a new solution. The whole problem is, I'm just not understanding enough about VB to really know what these error messages mean. The book doesn't tell you anything about error messages, doesn't tell you about debugging or the immediate window nor has any instruction been given on it. I feel like I'm drowning fast.
Reply With Quote
  #12  
Old 03-11-2003, 06:37 PM
MikeJ's Avatar
MikeJ MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,742
Default

Do you have an End Sub?
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #13  
Old 03-11-2003, 06:39 PM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

You have this in your general declarations section:

Code:
txt2x4x8.Text = "0"

Remove it.
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #14  
Old 03-11-2003, 06:43 PM
twirlerzmom twirlerzmom is offline
Freshman
 
Join Date: Mar 2003
Posts: 25
Default

MikeJ:

No, I didn't have an End Sub, but I added one now....still the same error message about method or data member not found;

Squirm:

I took it out, same error message as I told MikeJ
Reply With Quote
  #15  
Old 03-11-2003, 06:46 PM
MikeJ's Avatar
MikeJ MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,742
Default

Private Const csng2x4Price As Single = 0.16
Private Const csng2x6Price As Single = 0.22
Private Const csng2x8Price As Single = 0.31

Take out the equal sign and the decimals, and put under the form load event as:
csng2x8Price = 0.31, etc.
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #16  
Old 03-11-2003, 06:51 PM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

MikeJ, that is wrong.
The constants are in the right place.
This is how the code should look (and should work this way):

Code:
Option Explicit Dim pstrDeliveryCharge As Currency Dim pstrFeetCharge As Currency Public pintTotalFeet As Integer Private Const csng2x4Price As Single = 0.16 Private Const csng2x6Price As Single = 0.22 Private Const csng2x8Price As Single = 0.31 'txt2x4x8.Text = "0" <-- Notice this is commented out Dim mintIndex2x4Length As Integer Dim mintIndex2x6Length As Integer Dim mintIndex2x8Length As Integer Dim mintIndexDelivery As Integer Private Sub cmdNewOrder_Click() 'Rest of code
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #17  
Old 03-11-2003, 06:55 PM
twirlerzmom twirlerzmom is offline
Freshman
 
Join Date: Mar 2003
Posts: 25
Default

Quote:
Originally Posted by MikeJ
Private Const csng2x4Price As Single = 0.16
Private Const csng2x6Price As Single = 0.22
Private Const csng2x8Price As Single = 0.31

Take out the equal sign and the decimals, and put under the form load event as:
csng2x8Price = 0.31, etc.
I did that, left them as Private Const csng2x8Price As Single, etc
and put the price under form load like you suggested. Now I get this:

Compile Error:
Expected=
Reply With Quote
  #18  
Old 03-11-2003, 06:58 PM
MikeJ's Avatar
MikeJ MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,742
Default

OK, but I think it was tried that and it didn't work.
Quote:
Originally Posted by deadalus
Why would you have it in the Declarations section? In the Load sub like you had it seems fine. you can't assign a value to a variable in the Declarations section.
I think that was declaring a variable in the declarations. But then again, constants confuse me sometimes...

~MikeJ

Edit:
Take out the Const
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #19  
Old 03-11-2003, 07:04 PM
twirlerzmom twirlerzmom is offline
Freshman
 
Join Date: Mar 2003
Posts: 25
Default

Quote:
Originally Posted by Squirm
MikeJ, that is wrong.
The constants are in the right place.
This is how the code should look (and should work this way):

Code:
Option Explicit Dim pstrDeliveryCharge As Currency Dim pstrFeetCharge As Currency Public pintTotalFeet As Integer Private Const csng2x4Price As Single = 0.16 Private Const csng2x6Price As Single = 0.22 Private Const csng2x8Price As Single = 0.31 'txt2x4x8.Text = "0" <-- Notice this is commented out Dim mintIndex2x4Length As Integer Dim mintIndex2x6Length As Integer Dim mintIndex2x8Length As Integer Dim mintIndexDelivery As Integer Private Sub cmdNewOrder_Click() 'Rest of code
Squirm.....so I need to take out declaring the textboxes altogether? If I don't declare them my form has fits then in the cmdNewOrder part because it's looking for them. The newOrder is the part that is hanging me up because of those textboxes. It doesn't know what to do with them.....and either do I

I fixed the constants in the declarations though. I really appreciate the help you guys have been giving me too.
Reply With Quote
  #20  
Old 03-11-2003, 07:09 PM
MikeJ's Avatar
MikeJ MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,742
Default

Quote:
Originally Posted by twirlerzmom
so I need to take out declaring the textboxes altogether?
Are the textboxes on the form, or am I not reading this right? (seriously, I find it hard to understand some things sometimes)

Also, the Const give an unchangeable value.
Quote:
Originally Posted by MSDN
Unlike variables, constants can't be inadvertently changed while your program is running.
If you wish to change them, then do it the way above.
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginner VB again. Can you make a message box popup along w/summary on form displayed chrisk General 9 11-23-2002 04:01 PM
Beginner with VB - can't make form work to calculate discount with check box chrisk General 3 11-23-2002 02:31 PM
beginner Sarah Database and Reporting 2 04-11-2001 06:05 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->