CDROM-Guide forums

Go Back   CDROM-Guide forums > Main Forums > Open to All Computer Related Topics
FAQ Calendar Mark Forums Read
Open   CSec   Data   DevDrv   CoOp   Audio   CDRW   CDG   VCD   DVD   HD DVD   Mac   VGB   PS2   DC   Xbox  


Reply
 
Thread Tools Display Modes
  #1  
Old Mar 30, 2003, 10:28 AM
Mayo Mayo is offline
Senior Member
 
Join Date: May 2001
Posts: 225
Question ne1 help annotate my visual basic code??


 
hi, ok i need a bit of help with visual basic in access, i have written the code etc with the help of a family friend who is now away out of the country for the time being so he can't help.

ok so here's my problem:
all my code is written etc but just found out on friday that every line of the code needs to be annotated specifying what it does etc and i mean EVERY line but seeing as i'm not that familiar with VBA i don't know what each little object does but know what each page of code does so i was wonderin if u guys cud annotate the code for me in BASIC terms plz it wud be much appreciated

here's the codes:

1.

Private Sub Quantity_LostFocus()
If CDbl(Quantity.Value) > CDbl([Amount in stock].Value) Then
MsgBox "Only " & [Amount in stock].Value & " in stock !!"
Quantity.Value = Quantity.OldValue
Exit Sub
End If
[Item Value].Value = CDbl(Quantity.Value) * CDbl([Selling Price].Value)


End Sub

2.

Private Sub lstProducts_DblClick(Cancel As Integer)

Dim dblItemValue As Double
Dim strSQL As String
Dim lngTransFK As Long
Dim lngProductFK As Long
Dim lngQuantity As Long

lngProductFK = lstProducts.Column(0)
lngTransFK = Forms![frm_Transactions].txtTransID.Value

If CLng(lstProducts.Column(3)) = 0 Then Exit Sub
lngQuantity = 1
dblItemValue = CDbl(lstProducts.Column(2))

strSQL = "INSERT INTO tbl_transprod (TransactionFK, ProductFK, Quantity, TransactionValue) VALUES (" _
& lngTransFK & ", " & lngProductFK & "," & lngQuantity & ", " & dblItemValue & ")"
CurrentDb().Execute strSQL

Forms![frm_Transactions].subfrm_transprod.Requery


End Sub

3.

Private Sub txtDesc_Change()

Dim strRowSource As String
Dim strDesc As String

strRowSource = "SELECT [ID], [Product Description], [Selling Price], [Amount in Stock] FROM tbl_products"
strDesc = Trim(txtDesc.Text)
If Len(strDesc) > 0 Then
strRowSource = strRowSource & " WHERE [Product Description] LIKE ""*" & strDesc & "*"""
End If
lstProducts.RowSource = strRowSource
lstProducts.Requery

End Sub


if u cud do annotations in a different colour plz, hope it's not too much to ask but is very important
Reply With Quote
  #2  
Old Mar 30, 2003, 12:58 PM
yoshter1 yoshter1 is offline
Veteran
 
Join Date: Aug 2001
Location: Antarctica (Yes, the penguins DO use Linux down here)
Posts: 690
Default

Gah...it's been awhile since I've done VB(I'm a C++ kind of guy), but here goes:

1
Private Sub Quantity_LostFocus() - Declares the Sub

If CDbl(Quantity.Value) > CDbl([Amount in stock].Value) Then Uh, If the CDlb is less than the CDlb in the stock

Then do the following
MsgBox "Only " & [Amount in stock].Value & " in stock !!" opens a box saying that only the amount IN the stock is in THE stock(meaning you tried to exceed something)
Quantity.Value = Quantity.OldValue set the current value to equal the old value
Exit Sub Exits from this block of code
End If exits from the if statement

the below happens IF the CDbl is GREATER then the CDlb in the stock
[Item Value].Value = CDbl(Quantity.Value) * CDbl([Selling Price].Value)

End Sub ends sub
Reply With Quote
  #3  
Old Mar 30, 2003, 01:02 PM
yoshter1 yoshter1 is offline
Veteran
 
Join Date: Aug 2001
Location: Antarctica (Yes, the penguins DO use Linux down here)
Posts: 690
Default

3.

Private Sub txtDesc_Change() declares sub

Dim strRowSource As String declares a string?
Dim strDesc As String declares a string?

below, I think that's for selecting a product and info from a database(in this case, a table[tbl_products])
strRowSource = "SELECT [ID], [Product Description], [Selling Price], [Amount in Stock] FROM tbl_products"

strDesc = Trim(txtDesc.Text) the, uh, description string is set to the description of a product you pulled up

If Len(strDesc) > 0 Then if the length of strDesc is greater than 0 (in other words, if there is something in it)

then do the following
strRowSource = strRowSource & " WHERE [Product Description] LIKE ""*" & strDesc & "*""" does something to the product info...

End If ends the if statement

does these IF Len(strDesc is < 0(if its empty)

lstProducts.RowSource = strRowSource sets the list of prodcts to the source???

lstProducts.Requery tries to find something???

End Subends this little block of code

Last edited by yoshter1; Mar 30, 2003 at 01:08 PM.
Reply With Quote
  #4  
Old Mar 30, 2003, 02:01 PM
Mayo Mayo is offline
Senior Member
 
Join Date: May 2001
Posts: 225
Default

thanx m8, much appreciated
Reply With Quote
Reply

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help with my Visual Basic Code - easy code Nokia I Is Open to All Computer Related Topics 4 Oct 15, 2005 12:03 PM
Need some Visual Basic help. RedHerring24 Open to All Computer Related Topics 2 Feb 05, 2004 10:10 PM
Visual basic and changing a string inside a file help. Stusy Open to All Computer Related Topics 4 Jun 19, 2003 04:11 AM
Visual Basic 6.0 snakeman Open to All Computer Related Topics 0 Jan 18, 2003 03:28 PM
Visual basic and Licensing? itsallgood Open to All Computer Related Topics 7 Jul 05, 2002 01:40 AM


All times are GMT -5. The time now is 01:25 AM.



Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1996-2009 CDROM-Guide.com. All rights reserved