By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,101 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,101 IT Pros & Developers. It's quick & easy.

Advanced Programming

P: 93
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!
Mar 30 '07 #1
Share this Question
Share on Google+
12 Replies


P: 93
Just bumping this one back up the chain
Apr 2 '07 #2

Expert 5K+
P: 8,434
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?
Apr 2 '07 #3

vijaydiwakar
100+
P: 579
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
Apr 2 '07 #4

P: 9
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.
Apr 3 '07 #5

iburyak
Expert 100+
P: 1,017
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.GetOSRights

Do While Not rsResult.EOF
n = n + 1
Load mnuOS(n)
mnuOS(n).Caption = rsResult!Name
mnuOS(n).Tag = rsResult!os_id
If glCurrentOS = rsResult!os_id Then
mnuOS(n).Checked = True
glCurrentOS = CLng(mnuOS(n).Tag)
End If

mnuOS(n).Visible = True
rsResult.MoveNext
Loop[/PHP]

Hope it helps.
Good Luck.
Apr 3 '07 #6

P: 93
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
Apr 4 '07 #7

iburyak
Expert 100+
P: 1,017
Yes, you can say something like this:

[PHP]Label.backcolor = value_from_database_here.[/PHP]

Good Luck.
Apr 4 '07 #8

Expert 5K+
P: 8,434
Yes, you can say something like this:

[PHP]Label.backcolor = value_from_database_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
Expand|Select|Wrap|Line Numbers
  1. For Each ctl In Me.Controls
  2.   With ctl
  3.     .BackColor = LookupProperty(Me.Name, .Name, .BackColor)
  4.   End With
  5. 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 "propertybag". 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.
Apr 4 '07 #9

P: 93
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
Expand|Select|Wrap|Line Numbers
  1. For Each ctl In Me.Controls
  2.   With ctl
  3.     .BackColor = LookupProperty(Me.Name, .Name, .BackColor)
  4.   End With
  5. 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 "propertybag". 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
Apr 13 '07 #10

P: 93
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.BackColor = rs1!A

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

Thanks in advance
Apr 19 '07 #11

iburyak
Expert 100+
P: 1,017
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.
Expand|Select|Wrap|Line Numbers
  1. Dim Color As Long
  2.  
  3. Select Case UCase(rs1!A)
  4. Case "VBRED"
  5.     Color = vbRed
  6. Case "VBMAGENTA"
  7.     Color = vbMagenta
  8. Case "VBGREEN"
  9.     Color = vbGreen
  10. Else 
  11.     Color = Label1.BackColor 
  12. End Select
  13.  
  14. 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:
Expand|Select|Wrap|Line Numbers
  1. Label1.BackColor = 255
Good Luck.
Apr 19 '07 #12

Expert 5K+
P: 8,434
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.
Apr 19 '07 #13

Post your reply

Sign in to post your reply or Sign up for a free account.