CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    Dec 2012
    Posts
    7

    generating rollno and assing it to the textboxes in vb6 with ms-access

    i m doing project in admission management system. i want to generate the rollno like 10cs01,10it01,10ee01...according to the department of the students where 10-year;cs,it,ee-dept;01-number.i need anyone to solve this prblm.thnks in advance.........

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: generating rollno and assing it to the textboxes in vb6 with ms-access

    Not enough info but sounds like you just need to combine some values into a string. How would depend partly on where the values are coming from and what form they are in.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Dec 2012
    Posts
    7

    Re: generating rollno and assing it to the textboxes in vb6 with ms-access

    when i enter the dept of the student it will search for the last rollno in the database and increment it by one then assign it in the text boxes.i want it to be generated automatically.......i ve the code like this but it ill generate the same rollno for all entries but i want it to be in order.
    Code:
    Static icount As Integer
    icount = 0
    If Combo1.Text = "BTECH-IT" Then
    icount = icount + 1
    rno.Text = "10IT" & icount
    ElseIf Combo1.Text = "BE-AERO" Then
    icount = icount + 1
    rno.Text = "10AE" & icount
    End If

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: generating rollno and assing it to the textboxes in vb6 with ms-access

    Well for one thing there you are incrementing the number in either case so you would be skipping numbers along the way. Assuming you weren't resetting it to 0 every time as you are. You should delete the line that sets the icount to 0. You should use 2 different counters in this case. You should also set the initial value of the count vars to that of the last roll in your database.

    From the looks of it all of your items would get either "10AE 1" or "10IT 1"
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Dec 2012
    Posts
    7

    Re: generating rollno and assing it to the textboxes in vb6 with ms-access

    thanks for ur reply.i dont know how to set the initial value of the count vars to that of the last rollno in the database.so ill u send me the code for that.if u send me the code then it ill be helpful for me to finish my project and also i need the code to validate the date field and email field.email field should satisfy the following condition:
    (1) It is a must to have have only 1 @ and 1 or more . in the full e-mail
    string since it is possible to have e-mail with more than one dot like
    peter@student.edu.au
    (2) @ must appear before .

  6. #6
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: generating rollno and assing it to the textboxes in vb6 with ms-access

    I could not provide the code even if I wanted to as you have not provided the info that would be required to do so.

    That said it is far better that you try to write your own code and ask questions when you are stuck. If I or someone else writes it for you then you still would not know how or why it should be done that way.

    Basically you have to lookup the data in the database and then set your starting value based on what you retrieved from the db, once you have that then you simply increment the value as needed.
    Always use [code][/code] tags when posting code.

  7. #7
    Join Date
    Dec 2012
    Posts
    7

    Re: generating rollno and assing it to the textboxes in vb6 with ms-access

    to valid e-mail address which ill fufil the following primary conditions,i use the below code but it shows an invalid id if i try to give one @ symbol anywhere in the id.
    conditions:
    (1) It is a must to have have only 1 @ and 1 or more . in the full e-mail
    string since it is possible to have e-mail with more than one dot like
    peter@student.edu.au
    (2) @ must appear before .
    (3) Email like peter@student.edu. is an error although it
    fufil (1) and (2) but it sorts of violates the e-mail syntax with only
    a dot ending at the back
    Code:
    public Function CheckEmailAddy(Text as string) as Boolean
    
    Dim intWhereAt as Integer
    Dim intPeriod as Integer
    
    intWhereAt = InStr(1, Text, "@")
    intPeriod = InStr(1, Text, ".")
    If intWhereAt > intPeriod then Exit Function
    
    If intWhereAt > 0 And intPeriod > 0 then CheckEmailAddy = true
    
    End Function
    help me by correcting the code ..........

  8. #8
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: generating rollno and assing it to the textboxes in vb6 with ms-access

    It seems like you have moved on to a different question. Did you resolve the issue with the rollnumbers?
    Always use [code][/code] tags when posting code.

  9. #9
    Join Date
    Dec 2012
    Posts
    7

    Re: generating rollno and assing it to the textboxes in vb6 with ms-access

    not yet .....

  10. #10
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: generating rollno and assing it to the textboxes in vb6 with ms-access

    You really should stay on the question you have started the thread for. As for the other question about validating email. You should do a search, there are many examples online related to validating email addresses in various ways.
    Always use [code][/code] tags when posting code.

  11. #11
    Join Date
    Dec 2012
    Posts
    7

    Re: generating rollno and assing it to the textboxes in vb6 with ms-access

    Thanks for your suggestion.now i got my email address validation part over...

  12. #12
    Join Date
    Dec 2012
    Posts
    7

    Re: generating rollno and assing it to the textboxes in vb6 with ms-access

    now i got the solution for my rollno generation query..
    Code:
    Dim rs As New ADODB.Recordset
    If Combo1.Text = "BE-CSE" Then
    strSQL = "Select Count(*) From biodata where dept=' " & Combo1.Text & " ' "
    rs.Open strSQL, cn, adOpenKeyset, adLockReadOnly, adCmdText
    If Not rs.BOF And Not rs.EOF Then
         rno = "10cs" & rs.Fields(0).Value + 1
    End If
    rs.Close
    Set rs = Nothing
    ElseIf Combo1.Text = "BE-AERO" Then
    strSQL = "Select Count(*) From biodata where dept=' " & Combo1.Text & " ' "
    rs.Open strSQL, cn, adOpenKeyset, adLockReadOnly, adCmdText
    If Not rs.BOF And Not rs.EOF Then
         rno = "10AE" & rs.Fields(0).Value + 1
    End If
    rs.Close
    Set rs = Nothing

  13. #13
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: generating rollno and assing it to the textboxes in vb6 with ms-access

    or, make a RS2 connection, as long as they are different.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

Featured