7 Replies - 2300 Views - Last Post: 03 March 2013 - 09:13 PM Rate Topic: -----

#1 aswa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 13-February 13

inserting label boxes at run time

Posted 18 February 2013 - 07:57 AM

Hey this is my second post!

I know practically nothing in VB 6 and my teachers need me to do a project within a month, so i really need help!


This one form, acts as an inbox where the fields shown are- from,subject and date

the table name is msg, and the fields in that is- from, to, sub, dates, msg, read
and i've written a code in this "send message" form and it gets stored in this table

here "Username" is my global variable which has the user's id stored in it.

here's my code-

Private Sub Form_Load()
    Dim Getr As String
    
    Set rs = New ADODB.Recordset
    rs.Open "Select * from msg", cn, adOpenStatic, adLockOptimistic
    
    Getr = rs.Fields(2).value
    rs.MoveFirst
    
    
    'While (rs.EOF = False)
        If Getr = Username Then
            Label4.Caption = rs.Fields(1).value
            Label5.Caption = rs.Fields(3).value
            Label6.Caption = rs.Fields(4).value
            rs.MoveNext
            'rs.Close
        End If
    'Wend
    rs.Close
End Sub



this works in displaying only one of the messages..and i've hardcored the label boxes 4,5,6..
but since the number of messages in the inbox is more than one, i need to be able to dynamically add labels based on how many new messages i've got.

I'd really appreciate the help, and i hope i've explained my problem clearly

Is This A Good Question/Topic? 0
  • +

Replies To: inserting label boxes at run time

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5578
  • View blog
  • Posts: 11,918
  • Joined: 02-June 10

Re: inserting label boxes at run time

Posted 18 February 2013 - 08:23 AM

Your assignment is to do this in VB6? You're deliberately going to school to learn a language that's been dead for a decade? Should this be moved to VB.NET?

Please read: This is not the VB.NET forum
Please read: Is learning VB6 now a complete waste of time?

Quote

I know practically nothing in VB 6 and my teachers need me to do a project within a month, so i really need help!

Sounds like someone needs to do their job better.
Either you teacher needs to do their job and actually teach, or
you need to do your job an actively learn and ask questions until you understand the material. You have as much responsibility in being a good student as they do in being a good teacher.


The design of the app is terrible. You don't want to just keep creating labels. Make a single UserControl that is your email form. On it would be To: Subject: Date: Message and so on. Then for each email you add another email UserControl. You want to deal with things like an email as a single thing: An object. Don't micro-manage it by dealing with the dozens of little bits individually.

This is an Object Oriented language. Design in an Object Oriented way.


This post has been edited by tlhIn`toq: 18 February 2013 - 08:24 AM

Was This Post Helpful? 0
  • +
  • -

#3 aswa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 13-February 13

Re: inserting label boxes at run time

Posted 18 February 2013 - 09:04 AM

i'm sorry, but the teaching system in India doesn't quite work as you think.
the teachers don't know much themselves, we ask them to teach us useful stuff that would help us in the project, and they teach us how to put a picture onto a form, such sorts.

and as for using vb 6, it's prescribed by the university so it can't be changed. i need to do this project in vb 6 for me to pass.

i'll try what you've said.
Thank you!
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5578
  • View blog
  • Posts: 11,918
  • Joined: 02-June 10

Re: inserting label boxes at run time

Posted 18 February 2013 - 09:36 AM

I don't know what to say. I guess if everyone else in your country is using a language that is 10 years out of date, then you are equally equipped to get a job there.

But if it were me, I'd be studying a language on my own that has modern uses. I would make an effort to be the one guy out of 1,000 that could make a program for a modern operating system using modern techniques.

You obviously have internet access so there is a ton of on-line resources available.


My standard beginner resources post - Updated JAN 2013


Plan your study route:
There are three routes people seem to take when learning programming.
  • Just start trying to create programs
  • Start taking apart other programs and try to figure out the language by reverse engineering
  • Follow a guided learning course (school or self-teaching books)


For the life of me I can't figure out why people try 1 & 2. I strongly suggest taking the guided learning approach. Those book authors go in a certain order for a reason: They know what they're doing and they know the best order to learn the materials.

  • First learn the language by working 2-5 "Learn C# in 30 days" type books cover to cover.
  • Do a dozen on-line tutorial projects where you build what you're told to build, the way you are told to build it WITH AN EXPLANATION OF WHY so you can learn.
  • Learn to plan before you type.
  • THEN you start designing software with a purpose.



I don't learn from reading books: I learn by doing.
Spoiler


Newbie/Rookie said:

I have little/no programming experience but I need to write a program by Friday that does XYZ.
Spoiler



Resources, references and suggestions for new programmers.
Spoiler

Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: inserting label boxes at run time

Posted 20 February 2013 - 12:22 AM

Don't dynamically add labels (I think it's a poor design too). Just use a DataGrid to display your messages. Then, when a user clicks on one of the messages, display all the detail for that one in the form. Use Microsoft Outlook or Outlook Express for an example.
Was This Post Helpful? 0
  • +
  • -

#6 aswa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 13-February 13

Re: inserting label boxes at run time

Posted 25 February 2013 - 08:28 AM

View PostBobRodes, on 20 February 2013 - 12:22 AM, said:

Don't dynamically add labels (I think it's a poor design too). Just use a DataGrid to display your messages. Then, when a user clicks on one of the messages, display all the detail for that one in the form. Use Microsoft Outlook or Outlook Express for an example.


I used your idea on using data grid (please see the attached print screen), but I have a couple of questions.

1) well in the print screen, you'll see two columns "to" and "read". i don't want those columns to be displayed when i run the project. how do i do that?

2) also, the corresponding table in access contains the messages of all users..but i want the table to display the records only of those where "to" is the username..i'd like to know how to do that too

3) i'd also like to know the number of characters permitted per cell in access.

Thanks!
Was This Post Helpful? 0
  • +
  • -

#7 aswa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 13-February 13

Re: inserting label boxes at run time

Posted 25 February 2013 - 08:51 AM

View Postaswa, on 25 February 2013 - 08:28 AM, said:

View PostBobRodes, on 20 February 2013 - 12:22 AM, said:

Don't dynamically add labels (I think it's a poor design too). Just use a DataGrid to display your messages. Then, when a user clicks on one of the messages, display all the detail for that one in the form. Use Microsoft Outlook or Outlook Express for an example.


I used your idea on using data grid (please see the attached print screen), but I have a couple of questions.

1) well in the print screen, you'll see two columns "to" and "read". i don't want those columns to be displayed when i run the project. how do i do that?

2) also, the corresponding table in access contains the messages of all users..but i want the table to display the records only of those where "to" is the username..i'd like to know how to do that too

3) i'd also like to know the number of characters permitted per cell in access.

Thanks!



i'm sorry, for some reason, i'm unable to upload a print screen.
but as mentioned, amongst the columns in the datagrid, "to" and "read" are two columns.
Was This Post Helpful? 0
  • +
  • -

#8 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: inserting label boxes at run time

Posted 03 March 2013 - 09:13 PM

Look at the datagrid's columns property. If you want to make the first column invisible, set dbgrd.columns(0).Visible to false. Sorry, the doc is very sketchy here so this might not be the exact way to do it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1