Advanced Programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Taftheman
    New Member
    • Nov 2006
    • 93

    #1

    Advanced Programming

    Hello, I am not sure if anyone can help.
    one of my colleagues was talking about he knew some one that can build a form and all of it controls via a database. So in vb's case instead of drag and drop columns, he specified them in a table, and then refernced to a form. Or somthing like that. I seen a small section which my colleagues has written in .Net but it is very basic like changing the colour of a label. However i was wondering can this be done in VB6, and if so can some one point me to the write direction, like a tutorial or web page. If possible i would like to know for VB6 however, i am also begining to start to learn .Net so it would be helpful for that as well.

    Thanks in advance if anyone can help!
    Last edited by Killer42; Apr 10 '07, 10:02 AM. Reason: Correct a typo
  • Taftheman
    New Member
    • Nov 2006
    • 93

    #2
    Just bumping this one back up the chain

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by Taftheman
      Just bumping this one back up the chain
      I didn't spot this one before. However, I don't think it's really clear what you want to achieve. Could you try to explain again?

      Comment

      • vijaydiwakar
        Contributor
        • Feb 2007
        • 579

        #4
        Originally posted by Taftheman
        Hello, I am not sure if anyone can help.
        one of my colleges was talking about he knew some one that can build a form and all of it controls via a database. So in vb's case instead of drag and drop columns, he specified them in a table, and then refernced to a form. Or somthing like that. I seen a small section which my colleges has written in .Net but it is very basic like changing the colour of a label. However i was wondering can this be done in VB6, and if so can some one point me to the write direction, like a tutorial or web page. If possible i would like to know for VB6 however, i am also begining to start to learn .Net so it would be helpful for that as well.

        Thanks in advance if anyone can help!
        See if i got right then u like to create a UI independant of Database
        then this can be with the help of xml files also
        i've done it with the help of vbdot net and xml files
        Good Luck

        Comment

        • Traps
          New Member
          • Apr 2007
          • 9

          #5
          I've implemented the ability to create a dynamic form at runtime, using parameters in a file. If I can remember, I'll post some source. Its really easy.

          Comment

          • iburyak
            Recognized Expert Top Contributor
            • Nov 2006
            • 1016

            #6
            Originally posted by Taftheman
            Hello, I am not sure if anyone can help.
            one of my colleges was talking about he knew some one that can build a form and all of it controls via a database. So in vb's case instead of drag and drop columns, he specified them in a table, and then refernced to a form. Or somthing like that. I seen a small section which my colleges has written in .Net but it is very basic like changing the colour of a label. However i was wondering can this be done in VB6, and if so can some one point me to the write direction, like a tutorial or web page. If possible i would like to know for VB6 however, i am also begining to start to learn .Net so it would be helpful for that as well.

            Thanks in advance if anyone can help!
            See how I generate new menu items from a database.
            Assume I have mnuOS with index 0 and it is not visible.

            The rest could be built similarly. You can set Top, Left, Width, Height, Color for each control and all other possible properties.



            [PHP]Dim rsResult As ADODB.Recordset
            Dim objMainView As New clsMainView
            Dim n As Integer

            On Error GoTo ErrorHandler
            Set rsResult = objMainView.Get OSRights

            Do While Not rsResult.EOF
            n = n + 1
            Load mnuOS(n)
            mnuOS(n).Captio n = rsResult!Name
            mnuOS(n).Tag = rsResult!os_id
            If glCurrentOS = rsResult!os_id Then
            mnuOS(n).Checke d = True
            glCurrentOS = CLng(mnuOS(n).T ag)
            End If

            mnuOS(n).Visibl e = True
            rsResult.MoveNe xt
            Loop[/PHP]

            Hope it helps.
            Good Luck.

            Comment

            • Taftheman
              New Member
              • Nov 2006
              • 93

              #7
              Hi thanks for all your replys.
              for example if i had a lable and wanted this to be red insted of specifying it everytime. I have that in a table and every time i need it i reffer to it (a table in a database to make the label red).

              I hope this makes more sense. It can be done in .net as i have seen it, tho can some one point me to the right direction cheers

              Comment

              • iburyak
                Recognized Expert Top Contributor
                • Nov 2006
                • 1016

                #8
                Yes, you can say something like this:

                [PHP]Label.backcolor = value_from_data base_here.[/PHP]

                Good Luck.

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  Originally posted by iburyak
                  Yes, you can say something like this:

                  [PHP]Label.backcolor = value_from_data base_here.[/PHP]
                  You could take it a step further and loop through all the controls on your form, checking the name and loading values from your database for that name. Something like
                  Code:
                  For Each ctl In Me.Controls
                    With ctl
                      .BackColor = LookupProperty(Me.Name, .Name, .BackColor)
                    End With
                  Next
                  (The idea of passing the current BackColor was to provide a default value in case the lookup routine didn't find it in the database.)

                  Um...

                  Oh! Try looking up "propertyba g". I just remembered, in VB6 there's an object called a "property bag" which is used to hold the properties for a user control. Haven't had much experience with it, but it might be just what you're after.

                  Comment

                  • Taftheman
                    New Member
                    • Nov 2006
                    • 93

                    #10
                    Originally posted by Killer42
                    You could take it a step further and loop through all the controls on your form, checking the name and loading values from your database for that name. Something like
                    Code:
                    For Each ctl In Me.Controls
                      With ctl
                        .BackColor = LookupProperty(Me.Name, .Name, .BackColor)
                      End With
                    Next
                    (The idea of passing the current BackColor was to provide a default value in case the lookup routine didn't find it in the database.)

                    Um...

                    Oh! Try looking up "propertyba g". I just remembered, in VB6 there's an object called a "property bag" which is used to hold the properties for a user control. Haven't had much experience with it, but it might be just what you're after.
                    Hi again, i was looking at this, and it is exactly what i was looking for, to bw able to loop through the form, is there a website or somthing that i can get tutorials

                    Comment

                    • Taftheman
                      New Member
                      • Nov 2006
                      • 93

                      #11
                      I have made a start to this by changing the colour of a label, however i keep getting an error.

                      I have a database with the value vbRED in a column A

                      I then open up a connection to the database and run a simple select statement (Recordset)

                      Label1.BackColo r = rs1!A

                      but this does not work can some one guide to the right place

                      Thanks in advance

                      Comment

                      • iburyak
                        Recognized Expert Top Contributor
                        • Nov 2006
                        • 1016

                        #12
                        You have two options here:

                        1. Convert string function into a long by choosing from case. In this case you limited to options in your case.
                        Code:
                        Dim Color As Long
                        
                        Select Case UCase(rs1!A)
                        Case "VBRED"
                            Color = vbRed
                        Case "VBMAGENTA"
                            Color = vbMagenta
                        Case "VBGREEN"
                            Color = vbGreen
                        Else 
                            Color = Label1.BackColor 
                        End Select
                        
                        Label1.BackColor = Color
                        2. Save value of a variable into a database not a variable name

                        You have to save Clng(vbRed) as long not as string.

                        Try this test:
                        Code:
                        Label1.BackColor = 255
                        Good Luck.

                        Comment

                        • Killer42
                          Recognized Expert Expert
                          • Oct 2006
                          • 8429

                          #13
                          Yes, I would definitely save the values, not the name of a constant which contains it. For instance, vbRed is simply a Long containing the value 255.

                          Don't know how you would go about converting the string "vbRed" to the value of the constant. Apart from the brute-force Select Case of course, like iburyak said. Much simpler to just store the actual values from the properties. (I think I mentioned, there is a thing called a propertybag which may be useful in this regard - you probably should check it out, but I don't remember anything about it except that it is used to hold a bunch of properties and their values.)

                          Also, something else I may have mentioned before - keep an eye out for the values indicating Windows system colours (Eg. "Button Face" = &H8000000F&) . They may not be any problem in your situation, but I ran into problems when I was splitting up colours into their R/G/B components, because they're four-byte values rather than three.

                          Comment

                          Working...