Results 1 to 27 of 27

Thread: Modules...what are they???

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Location
    California
    Posts
    3

    Question

    What the heck are modules? After a year of VB6 programming my teacher never once mentioned modules... come to think of it, we didnt learn much, heh.

    What's a good book that will teach me about data-types and modules and pretty much everything else VB?


    Thanks a lot
    I am l33t
    I am a H4x0r
    I am a l33t H4x0r
    (j/k =) )

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Canada
    Posts
    264
    Modules are for sharing information between forms, if you want to have some globals variables lets say, you put it in the module, and than all your forms for this project can use this variable.

    Same thing for functions/subs, just put it in the module and all your forms can "see" and use it.

    A good book:

    VB6.0 in 21 days by SAMS

    cheers
    In the beginning the universe was created. This has made a lot of people very angry and is generally regarded as a bad idea.

    - Douglas Adams
    The Hitchhiker's Guide to the Galaxy

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Modules simple answer

    I use module to place code that really doesn't go with a spcific form ie :

    Standard print command

    API commands

    Conversion formulas (sting to value,value to string)

    Declaring global variables - which more than one form may have to "see" the value.

    I have read opinions on this Module concept and some people feel it is wasted space. I think it simplifies and provides a better means of reusable code.

    Just my thoughts...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Well, if you re-use code between various forms, put it in a module so it will (as stated by the other replies) be available for all forms.
    I use it for some api calls but the most for global functions, a good programmer can't live without them!
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5
    Also, modules are just text files. There is no graphical interface to them (i.e., not like forms). Strangly enough, you can give them names just like any other object, though....

  6. #6
    Junior Member
    Join Date
    Feb 2004
    Posts
    25
    I've been wondering about modules myself. I've been doing VB for two weeks now (lucky me!).

    I have a few db queries that I would like to share between different forms, as well as different Subs within individual forms. Would these be good reasons to use modules?

    I've tried to run a db query from a module, but I had no luck. I wasn't sure how to write the module out... Do I need to write it as a function or a Sub within the module? Any help would be appreciated.

    Josh

  7. #7
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Yes, you could write functions/subs that would perform the query on the database and perhaps output results somehow.
    If you wanted to store the results you could declare a variable in the module, the variable would be 'seen' by all forms in your project.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  8. #8
    Junior Member
    Join Date
    Feb 2004
    Posts
    25
    Can you please give me a quick example? I think it's the variable setting part that's killing me. I can't figure out the syntax to assign a variable in the module, and then how to call that variable in a form to reference it.

    What I'm trying to do is run a query to look up a tax percentage in a database table, assign that number to a variable, and then be able to do some basic math in a form by referencing that tax percentage variable.

    Thanks,
    Josh

  9. #9
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959
    Modules allow for a tidier code, you could put all the module code in your main form code, but by using the module, evrything becomes a bit more organised and easier to read. Your main code will link to the module code to look for a function when it comes up against something it doesnt understand or hasnt been declared.

  10. #10
    Junior Member
    Join Date
    Feb 2004
    Posts
    25
    I understand that part. In this particular case I would like to store the tax percentage in a module because it gets used in different places in my code. For example, I need to display the tax percentage (7.2%, for example) so the user knows what it is. I also need to use that percentage to come up with the total order price (subtotal multiplied by the tax). I figure that if I write the tax percentage query in a module, I can then assign the percentage to a variable in the module and then call that variable in several other places in my project.

    The problem is, I don't know how to write the code to do it. I am hoping for a quick example so I can stop being stupid.

  11. #11
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    If my memory serves me correctly you use 'Global' instead of 'Dim' if you want to make a variable in a module that can be accessed by all forms.
    Other than that it's all exactly the same as if it were in a form.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  12. #12
    Junior Member
    Join Date
    Feb 2004
    Posts
    25
    Okay, so let me see if this makes sense. Here is what I'm running in the module to get the percentage. ("db" is set in the main form I have.)


    VB Code:
    1. Sub Get_The_Damn_Tax_Already()
    2.     ' Get the current tax rate from the lkpTax table and display it
    3.     Global Get_Tax As ADODB.Recordset
    4.     Set Get_Tax = New ADODB.Recordset
    5.  
    6.     Get_Tax.Source = "Select Tax_Rate from lkpTax"
    7.     Set Get_Tax.ActiveConnection = db
    8.     Get_Tax.Open
    9.     Get_Tax.MoveFirst
    10. End Sub

    So, do I now have to create another Global variable (call it something like "display_perc") in the Sub? In other words:

    VB Code:
    1. Global display_perc = Get_Tax.Fields!Tax_Rate

    Is that correct?
    Josh

  13. #13
    Addicted Member Aldragor's Avatar
    Join Date
    Oct 2002
    Location
    Québec, Canada
    Posts
    140
    Put the reserved word Public in front!


    Public Sub ....

    or

    Public Function ...

    if you want to access it from other forms or modules.

    For your variable.... you have to put it in the declaration part of the module. (At the top, not in a sub or function).

    Hope that help.
    Mens sana in corpore sano
    ... pour mieux travailler!

  14. #14
    Junior Member
    Join Date
    Feb 2004
    Posts
    25
    Okay, did that. Now how to call the variable.

    Man, am I a pain in the butt or what?
    Josh Sager
    www.buyubooks.com
    www.tlavideo.com
    www.shinobi.org

    "Ya know, it's much easier in ColdFusion!"

  15. #15
    Addicted Member Aldragor's Avatar
    Join Date
    Oct 2002
    Location
    Québec, Canada
    Posts
    140
    Here is an exemple of a module

    VB Code:
    1. Option Explicit
    2.  
    3. Private Type SAFEARRAYBOUND
    4.     cElements As Long
    5.     lLbound As Long
    6. End Type
    7.  
    8. Private Type SAFEARRAY2D
    9.     cDims As Integer
    10.     fFeatures As Integer
    11.     cbElements As Long
    12.     cLocks As Long
    13.     pvData As Long
    14.     Bounds(0 To 1) As SAFEARRAYBOUND
    15. End Type
    16.  
    17. Private Type BITMAP '14 bytes
    18.     bmType As Long
    19.     bmWidth As Long
    20.     bmHeight As Long
    21.     bmWidthBytes As Long
    22.     bmPlanes As Integer
    23.     bmBitsPixel As Integer
    24.     bmBits As Long
    25. End Type
    26.  
    27. Public Const SRCPAINT = &HEE0086        ' (DWORD) dest = source OR dest
    28. Public Const SRCINVERT = &H660046       ' (DWORD) dest = source XOR dest
    29. Public Const SRCERASE = &H440328        ' (DWORD) dest = source AND (NOT dest )
    30. Public Const SRCCOPY = &HCC0020         ' (DWORD) dest = source
    31. Public Const SRCAND = &H8800C6          ' (DWORD) dest = source AND dest
    32. Public Const DSTINVERT = &H550009       ' (DWORD) dest = (NOT dest)
    33. Public Const NOTSRCCOPY = &H330008      ' (DWORD) dest = (NOT source)
    34. Public Const NOTSRCERASE = &H1100A6     ' (DWORD) dest = (NOT src) AND (NOT dest)
    35. Public Const MERGECOPY = &HC000CA       ' (DWORD) dest = (source AND pattern)
    36. Public Const MERGEPAINT = &HBB0226      ' (DWORD) dest = (NOT source) OR dest
    37. Public Const PATCOPY = &HF00021         ' (DWORD) dest = pattern
    38. Public Const PATINVERT = &H5A0049       ' (DWORD) dest = pattern XOR dest
    39. Public Const PATPAINT = &HFB0A09        ' (DWORD) dest = DPSnoo
    40. Public Const WHITENESS = &HFF0062       ' (DWORD) dest = WHITE
    41. Public Const BLACKNESS = &H42           ' (DWORD) dest = BLACK
    42.  
    43. 'Public myPicture As New StdPicture
    44.  
    45. Private Declare Function VarPtrArray Lib "msvbvm50.dll" Alias "VarPtr" (Ptr() As Any) As Long
    46. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
    47. Private Declare Function GetObjectAPI Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
    48.  
    49. Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    50. Public Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
    51. Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
    52. Public Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
    53. Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    54. Public Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    55.  
    56. Public Function Transform(ByVal myPicture As StdPicture, NewColor As Long, TransColor As Long) As StdPicture
    57.     Dim lMax As Long, lMid As Long, lMin As Long
    58.     Dim p As Integer, q As Integer, t As Integer, z As Integer
    59.     Dim lDifference As Single
    60.     Dim Hue As Single
    61.     Dim Luminance As Single
    62.     Dim Saturation As Single
    63.     Dim pic() As Byte
    64.     Dim sa As SAFEARRAY2D
    65.     Dim bmp As BITMAP
    66.     Dim R As Long, G As Long, B As Long
    67.     Dim transR As Long, transG As Long, transB As Long
    68.     Dim i As Integer, j As Integer
    69.    
    70.  ' the code here
    71.  
    72.     Set Transform = myPicture
    73. End Function
    74.  
    75.  
    76. Public Function ReplaceColor(ByVal myPicture As StdPicture, OldColor As Long, NewColor As Long, Similar As Long) As StdPicture
    77.     Dim pic() As Byte
    78.     Dim sa As SAFEARRAY2D
    79.     Dim bmp As BITMAP
    80.     Dim R_New As Long, G_New As Long, B_New As Long
    81.     Dim R_Old As Long, G_Old As Long, B_Old As Long
    82.     Dim R_Min As Long, G_Min As Long, B_Min As Long
    83.     Dim R_Max As Long, G_Max As Long, B_Max As Long
    84.     Dim R As Long, G As Long, B As Long
    85.     Dim i As Integer, j As Integer
    86.    
    87.    'your code here
    88.  
    89. End Function
    Mens sana in corpore sano
    ... pour mieux travailler!

  16. #16
    Junior Member
    Join Date
    Feb 2004
    Posts
    25
    So after the "Transform" function, you are setting a variable called "transform" and that variable can be called outside of the module by doing somthing like this:

    label_rate.Caption = Transform

    Is that right? I feel like I'm missing something...
    Josh Sager
    www.buyubooks.com
    www.tlavideo.com
    www.shinobi.org

    "Ya know, it's much easier in ColdFusion!"

  17. #17
    Junior Member
    Join Date
    Feb 2004
    Posts
    25
    I just realized that I hijacked the thread. I apologize to Lost_Light; I hope you're not offended...

    I changed my thinking a bit, but I'm still lost. I tried turning the module into a function. Here's what I have so far:

    VB Code:
    1. Global The_Damn_Tax_Rate As String
    2.  
    3. Public Function Get_The_Damn_Tax_Already()
    4.     ' Get the current tax rate from the lkpTax table and display it
    5.     Dim Get_Tax As ADODB.Recordset
    6.     Set Get_Tax = New ADODB.Recordset
    7.  
    8.     Get_Tax.Source = "Select Tax_Rate from lkpTax"
    9.     Set Get_Tax.ActiveConnection = db
    10.     Get_Tax.Open
    11.         Get_Tax.MoveFirst
    12.     Get_Tax.Close
    13.    
    14.     Set The_Damn_Tax_Rate = Get_Tax.Fields!Tax_Rate
    15. End Function


    Then, in Sub Form_Load() on the form, I have this:

    VB Code:
    1. Call Module1.Get_The_Damn_Tax_Already
    2.     label_tax_percentage.Caption = The_Damn_Tax_Rate

    I'm sure I'm not setting "The_Damn_Tax_Rate" correctly in either place.
    Josh Sager
    www.buyubooks.com
    www.tlavideo.com
    www.shinobi.org

    "Ya know, it's much easier in ColdFusion!"

  18. #18
    Lively Member
    Join Date
    May 2003
    Location
    Los Angeles
    Posts
    126
    See if this example and explanation will help you get your mind wrapped around using modules. They really are quite simple.

    First .... MS recommends that you NEVER use GLOBAL variables. Security problem!!! Instead use Public. They can be seen anywhere in your project, but not by something outside of your app.
    Here is some code that opens an Access Database from a module
    then uses the recordset in a form.

    VB Code:
    1. 'Module is called "modTestConnect"
    2. Option Explicit
    3. 'The Connection and Recordset objects are visible to any procedure that calls them.
    4.  
    5. Public cnMyCon As ADODB.Connection 'Connection to ADODB
    6. Public MyRS As ADODB.Recordset 'Holds records
    7.  
    8.  
    9. Public Sub ConnectToDBase(strSQL As String, Optional blnDel As Boolean)
    10. Dim lngRecordCount As Long
    11.      
    12.      Set cnMyCon = New ADODB.Connection
    13.      Set MyRS = New ADODB.Recordset
    14.      
    15.     MyRS.CursorLocation = adUseClient
    16.    
    17.    cnMyCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Test.mdb;Persist Security Info=False"
    18.    cnMyCon.CursorLocation = adUseClient
    19.    
    20.    MyRS.Open strSQL, cnMyCon, adOpenDynamic, adLockOptimistic
    21.      If blnDel = True Then
    22.           Exit Sub
    23.      End If
    24.    If Not MyRS.EOF Or Not MyRS.BOF Then
    25.      MyRS.MoveLast 'without these the recordcount
    26.      MyRS.MoveFirst 'ends up -1
    27.    End If
    28.    
    29.    lngRecordCount = MyRS.RecordCount
    30. End Sub
    31. Public Sub DisconnectDBase()
    32.      
    33.      If MyRS.State = adStateOpen Then
    34.           MyRS.Close
    35.      End If
    36.      cnMyCon.Close
    37.      Set MyRS = Nothing
    38.      Set cnMyCon = Nothing
    39. End Sub
    40.  
    41. 'Form code
    42. 'Several procedures shown here
    43.  
    44.  
    45. Private Sub MakeConnection() 'called from Form_Load event
    46. Dim strSQL As String
    47.  
    48.      Me.MousePointer = vbHourglass
    49. 'SQL statement that will be passed to module
    50.      strSQL = "SELECT CompanyName FROM Suppliers WHERE dropped = false;"
    51.  
    52. 'calling the module and passing it the required input(strSQL)
    53.      modTestConnect.ConnectToDBase strSQL
    54.      
    55. 'Other procedures
    56. LoadControls ' <<< Notice this routine below. It uses the
    57.                         'RecordSet created above
    58.      ResetOpt
    59. 'Other procedures that need this RecordSet are called BEFORE
    60. 'the RS is closed.
    61.     MyRS.Close  
    62.     Me.MousePointer = vbNormal
    63. End Sub
    In the above we made a module to connect to the DBase, and have variables that can be seen by any form.
    Another Routine in the same form that above code was taken from
    VB Code:
    1. Private Sub LoadControls() 'Loading Dynamic Controls
    2. Dim i As Integer
    3. Dim strName As String
    4.  
    5.      Do Until MyRS.EOF  '<< MyRS is Public in module' No need to
    6.                               'Dim a variable for it.
    7.   'Using the recordset    
    8.     strName = MyRS.Fields.Item("CompanyName").Value
    9.      Option1(i).Caption = strName
    10.       With Option1(i)
    11.              If i > 0 Then
    12.                .Top = Option1(i - 1).Top + Option1(i - 1).Height + 10
    13.                .Left = Option1(i - 1).Left
    14.                .Width = Frame1.Width - 500
    15.              End If
    16.              .Visible = True
    17.              .Value = False
    18.        End With
    19.        i = i + 1
    20.          
    21.        MyRS.MoveNext
    22.        If Not MyRS.EOF Then
    23.           Load Option1(i)
    24.        End If
    25.  
    26. Loop
    HTH
    Michael

  19. #19
    Junior Member
    Join Date
    Feb 2004
    Posts
    25
    Michael,

    I'm convinced that I'm the dumbest person on the planet. In the example you gave, you set a variable called "lngRecordCount." Is that one of the variables that you call from a form? If so, how do you actually use that variable in the form code?
    Josh Sager
    www.buyubooks.com
    www.tlavideo.com
    www.shinobi.org

    "Ya know, it's much easier in ColdFusion!"

  20. #20
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,191
    You can't the function is using it...

  21. #21
    Junior Member
    Join Date
    Feb 2004
    Posts
    25
    Originally posted by NoteMe
    You can't the function is using it...
    I can't what? I'm lost...
    Josh Sager
    www.buyubooks.com
    www.tlavideo.com
    www.shinobi.org

    "Ya know, it's much easier in ColdFusion!"

  22. #22
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175
    I haven't read all the posts in this thread but the use of modules is very simple. Here is a trivial example of sharing a variable between two forms.

    VB Code:
    1. 'In the module
    2. Option Explicit
    3.  
    4. Public gintCount As Integer
    5.  
    6. ' In Form1
    7. Private Sub Form_Load()
    8.  
    9.     gintCount = gintCount + 1
    10.     MsgBox gintCount ' Will display "1"
    11.     Form2.Show
    12.    
    13. End Sub
    14.  
    15. ' In Form2
    16. Private Sub Form_Load()
    17.  
    18.     gintCount = gintCount + 1
    19.     MsgBox gintCount ' Will display "2"
    20.  
    21. End Sub

  23. #23
    Junior Member
    Join Date
    Feb 2004
    Posts
    25
    Okay, I'm going to try this a different way. Here is the code I have so far. If you could just tell me what is wrong (in other words, actually tell me what I need to change to make this work), I think that will be the best way for me to figure out why it's not working. I now understand the idea of how to use modules; I just don't understand why my particular code isn't working.

    Here is the module:

    VB Code:
    1. Option Explicit
    2.  
    3. Public The_Damn_Tax_Rate As String
    4.  
    5. Public Sub Get_The_Damn_Tax_Already()
    6.     ' Get the current tax rate from the lkpTax table and display it
    7.     Dim Get_Tax As ADODB.Recordset
    8.     Set Get_Tax = New ADODB.Recordset
    9.  
    10.     Get_Tax.Source = "Select Tax_Rate from lkpTax"
    11.     Set Get_Tax.ActiveConnection = db
    12.     Get_Tax.Open
    13.         Get_Tax.MoveFirst
    14.         Set The_Damn_Tax_Rate = Get_Tax.Fields!Tax_Rate
    15.     Get_Tax.Close
    16. End Sub


    Here is the code I'm using on the form to try and use the variable I set in the module:

    VB Code:
    1. label_tax_percentage.Caption = Module1.The_Damn_Tax_Rate


    If you can tell me what exactly it is that I'm doing wrong, that should end this thread (and my misery).
    Josh Sager
    www.buyubooks.com
    www.tlavideo.com
    www.shinobi.org

    "Ya know, it's much easier in ColdFusion!"

  24. #24
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175
    The Set in the following is wrong and you should remove it. Set is for objects and not simple variables. You should also replace the "!" with a ".".

    VB Code:
    1. Set The_Damn_Tax_Rate = Get_Tax.Fields!Tax_Rate

    You don't need Module1 in the following since anything declared as Public in a module is known everywhere.

    VB Code:
    1. label_tax_percentage.Caption = Module1.The_Damn_Tax_Rate

  25. #25
    Junior Member
    Join Date
    Feb 2004
    Posts
    25
    I actually got it to work. For the life of me I don't know how, but here's what I did:

    VB Code:
    1. Option Explicit
    2.  
    3. Public dbTax As ADODB.Connection
    4. Public Get_Tax As ADODB.Recordset
    5. Public The_Damn_Tax_Rate As String
    6.    
    7. Public Sub Get_The_Damn_Tax_Already()
    8.  
    9.     Set dbTax = New ADODB.Connection
    10.     Set Get_Tax = New ADODB.Recordset
    11.  
    12.     dbTax.ConnectionString = "DSN=Mobile_Sales_App_Database;"
    13.     dbTax.Open
    14.  
    15.     ' Get the current tax rate from the lkpTax table
    16.     Get_Tax.Source = "Select Tax_Rate from lkpTax"
    17.     Set Get_Tax.ActiveConnection = dbTax
    18.     Get_Tax.Open
    19.         Get_Tax.MoveFirst
    20.         The_Damn_Tax_Rate = Get_Tax.Fields!Tax_Rate
    21.        
    22. End Sub
    23.    
    24. Public Sub DisconnectDBase()
    25.     If Get_Tax.State = adStateOpen Then
    26.           Get_Tax.Close
    27.      End If
    28.      dbTax.Close
    29.      Set Get_Tax = Nothing
    30.      Set dbTax = Nothing
    31. End Sub

    In the form I did this:

    VB Code:
    1. Call Get_The_Damn_Tax_Already
    2.     label_tax_percentage.Caption = The_Damn_Tax_Rate

    I'm sure there is a more efficient way of doing it, but this will do for now.

    Thanks to everyone for all of your help. I hope I wasn't too frustrating.
    Josh Sager
    www.buyubooks.com
    www.tlavideo.com
    www.shinobi.org

    "Ya know, it's much easier in ColdFusion!"

  26. #26
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175
    Hope this isn't confusing but you don't need your Public variable if you turn the sub into a function.


    VB Code:
    1. Option Explicit
    2.  
    3. Public dbTax As ADODB.Connection
    4. Public Get_Tax As ADODB.Recordset
    5. 'Public The_Damn_Tax_Rate As String You don't need this
    6.    
    7. Public [b]Function [/b]Get_The_Damn_Tax_Already() [b]As String[/b]
    8.  
    9.     Set dbTax = New ADODB.Connection
    10.     Set Get_Tax = New ADODB.Recordset
    11.  
    12.     dbTax.ConnectionString = "DSN=Mobile_Sales_App_Database;"
    13.     dbTax.Open
    14.  
    15.     ' Get the current tax rate from the lkpTax table
    16.     Get_Tax.Source = "Select Tax_Rate from lkpTax"
    17.     Set Get_Tax.ActiveConnection = dbTax
    18.     Get_Tax.Open
    19.         Get_Tax.MoveFirst
    20.         'The_Damn_Tax_Rate = Get_Tax.Fields!Tax_Rate
    21.         [b]Get_The_Damn_Tax_Already = Get_Tax.Fields!Tax_Rate[/b]
    22.        
    23. End Function
    24.    
    25. Public Sub DisconnectDBase()
    26.     If Get_Tax.State = adStateOpen Then
    27.           Get_Tax.Close
    28.      End If
    29.      dbTax.Close
    30.      Set Get_Tax = Nothing
    31.      Set dbTax = Nothing
    32. End Sub
    33. 'In the form
    34.     'Call Get_The_Damn_Tax_Already
    35.     'label_tax_percentage.Caption = Get_The_Damn_Tax_Already
    36.     [b]label_tax_percentage.Caption = Get_The_Damn_Tax_Already[/b]

  27. #27
    Junior Member
    Join Date
    Feb 2004
    Posts
    25
    That worked perfect, thanks. I think that was the one thing that was NOT confusing about this.

    Thank you for all of your help.
    Josh Sager
    www.buyubooks.com
    www.tlavideo.com
    www.shinobi.org

    "Ya know, it's much easier in ColdFusion!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width