Page 1 of 3 123 LastLast
Results 1 to 40 of 81

Thread: Quick easy Question

  1. #1

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219

    Quick easy Question

    Hi, For security for my program i get the HD #. After i get that i need to display it in a text box. I know how to do every thing ecept how to make the variable(HD#) appear in the text box with out pressing a buttun. As u can see the HD# is added to the text box with the event of a button click but i need to know how to put it all in into one thing without pressing a button.(Add the HD# to the text box with out pressing a button) Thanks


    VB Code:
    1. Function GetSerialNumber(ByRef strDrive As String) As Integer
    2.         Dim SerialNum As Integer
    3.         Dim Res As Integer
    4.         Dim Temp1 As String
    5.         Dim Temp2 As String
    6.         '
    7.         Temp1 = New String(Chr(0), 255)
    8.         Temp2 = New String(Chr(0), 255)
    9.         Res = GetVolumeInformation(strDrive, Temp1, Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2))
    10.         GetSerialNumber = SerialNum
    11.  
    12.     End Function
    13.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    14.  
    15.         hi = "" & GetSerialNumber("C:\")
    16.        
    17.         TextBox2.Text = (hi)
    18.  
    19.     End Sub
    -Rob

  2. #2
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Smile

    VB Code:
    1. Function GetSerialNumber(ByRef strDrive As String) As Integer
    2.         Dim SerialNum As Integer
    3.         Dim Res As Integer
    4.         Dim Temp1 As String
    5.         Dim Temp2 As String
    6.         '
    7.         Temp1 = New String(Chr(0), 255)
    8.         Temp2 = New String(Chr(0), 255)
    9.         Res = GetVolumeInformation(strDrive, Temp1, Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2))
    10.         GetSerialNumber = SerialNum
    11.  
    12.     End Function
    13.  
    14.     Private Sub Form_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
    15.  
    16.         hi = "" & GetSerialNumber("C:\")
    17.        
    18.         TextBox2.Text = (hi)
    19.  
    20.     End Sub

  3. #3

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    Ok thank you that worked!! Now one more question in this string how do i make the form(form3) exit after the correct password is entered. so as form1 is loaded i want form 3 to exit. Thanks

    VB Code:
    1. If TextBox1.Text = 2 Then frmform1.Show()
    -Rob

  4. #4
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by VBGangsta
    Ok thank you that worked!! Now one more question in this string how do i make the form(form3) exit after the correct password is entered. so as form1 is loaded i want form 3 to exit. Thanks

    VB Code:
    1. If TextBox1.Text = 2 Then frmform1.Show()
    form.hide or form.close

  5. #5

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    where do i do put it?
    -Rob

  6. #6
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by VBGangsta
    where do i do put it?
    ........

  7. #7

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    where do u put form.close in that string??
    -Rob

  8. #8
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by VBGangsta
    where do u put form.close in that string??
    form.close() is a function, you run it and it closes the forum.

    Dude.....just dude....

  9. #9

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    yeah but i get an error. An unhandled exception of type 'System.NullReferenceException
    -Rob

  10. #10
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by VBGangsta
    yeah but i get an error. An unhandled exception of type 'System.NullReferenceException
    ........

    vagueness is at an all time high today...

  11. #11

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    Originally posted by VBGangsta
    Ok thank you that worked!! Now one more question in this string how do i make the form(form3) exit after the correct password is entered. so as form1 is loaded i want form 3 to exit. Thanks

    VB Code:
    1. If TextBox1.Text = 2 Then frmform1.Show()
    do you see that code? well when the number 2 is entered(the correct password) i want my main form (form1) to load in which it does fine but i dont want the login form (form3) to stay open if the password is corect. So where do i put the form.close function. Is that enough detail???
    -Rob

  12. #12
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by VBGangsta
    do you see that code? well when the number 2 is entered(the correct password) i want my main form (form1) to load in which it does fine but i dont want the login form (form3) to stay open if the password is corect. So where do i put the form.close function. Is that enough detail???
    Dude...... stop programming now.... jesus...

    VB Code:
    1. If TextBox1.Text = 2 Then
    2. frmform1.Show()
    3. form3.close()
    4. end if

    This is simple stuff. Even if you got no clue what the syntax is, it is extremely easy to figure out where you would actually put it

  13. #13

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    Maybe your the one who should stop programming because thats wrong.
    -Rob

  14. #14
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Don't let him bother you VbGangsta keep at it.

    Is this code being executed inside of the login form (form3)? If so then you can use:
    VB Code:
    1. If TextBox1.Text = "2" Then
    2.      Dim frm As New frmform1 'create a new instance of the form
    3.      frm.Show() 'show it
    4.      Me.close() 'close the form that is running this code (form3)
    5. End If
    This also depends on if frmform1 is the name of the form class or the variable that you previously made.

  15. #15

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    Thanks Edneeis. That code is very close, after i type in the password "2" it closes form3 (the loging form) but either it is also closing the mainform(form1) or it is not even loading it because as soon as i press OK to the password form1 doesnt open. But form3 does close. Thanks Again!!
    -Rob

  16. #16
    Addicted Member The Phoenix's Avatar
    Join Date
    Aug 2003
    Location
    With my wife
    Posts
    142
    The problem is probably frmform1 isn't the name of your form. In design view, Click on the form that is supposed to show up, and look at the "(Name)" property. Use what ever is in the field to replace "frmform1" in the code Edneeis gave you.
    Take my love
    Take my land
    Take me where I cannot stand
    I don't care, I'm still free
    You can't take the sky from me...

  17. #17
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Do you have the application set to start with form3 or the login form? If so then that is the trouble. The first form shown cares the thread for the whole application and can not be closed without closing the whole application. There are several ways around this some are: hiding instead of closing the form3, starting from a module instead of form (I would use that one)...

    If you do a search on this forum you will see what other people did to resolve this (If you are starting the app with form3).

    Try here:
    http://www.vbforums.com/showthread.p...hreadid=209896
    Last edited by Edneeis; Oct 3rd, 2003 at 09:55 AM.

  18. #18
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by VBGangsta
    Maybe your the one who should stop programming because thats wrong.
    dumbass

  19. #19
    Addicted Member The Phoenix's Avatar
    Join Date
    Aug 2003
    Location
    With my wife
    Posts
    142
    Here's a small program I wipped up. It should do what you are tyring to do. Hope it helps.

    I had this exact same question when I started out in .NET, so ignore kasracer, you are doing fine.
    Attached Files Attached Files
    Take my love
    Take my land
    Take me where I cannot stand
    I don't care, I'm still free
    You can't take the sky from me...

  20. #20
    Addicted Member
    Join Date
    Dec 2002
    Location
    Central US
    Posts
    183

    Thumbs down

    Originally posted by kasracer
    dumbass

    Kasracer!
    Did you come into this World knowing it all?
    If so “our deepest apologies”

  21. #21
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Rally
    Kasracer!
    Did you come into this World knowing it all?
    If so “our deepest apologies”
    No, but he is asking where to put stuff, that should be common sence.

    You want a message box to come up when the user hits a button? Use the on click event. hell just double click the button and add code.

    It isn't difficult at all.

    Also, not changing the form name is pretty damn stupid, I mean come on. If he knows enough to name a form, he should be able to put 2 and 2 together when VB says form3 doesn't exist.

  22. #22
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    This is a forum, people come here for help, so why are you razing him for doing just that? Is that how you pump yourself up by putting others down? Are you a big man now that you have given someone who is just starting out a hard time about what you deem they should already know or should be common sense? Who made you the judge of all things? The declarer of what is and isn't common sense? If you don't like his question then don't answer it. And on top of it all your're code didn't work either so how much common sense do you have?
    Last edited by Edneeis; Oct 3rd, 2003 at 03:42 PM.

  23. #23
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Edneeis
    This is a forum, people come here for help, so why are you razing him for doing just that? Is that how you pump yourself up by putting others down? Are you a big man now that you have given someone who is just starting out a hard time about what you deem they should already know or should be common sense? Who made you the judge of all things? The declarer of what is and isn't common sense? If you don't like his question then don't answer it. And on top of it all your're code didn't work either so how much common sense do you have?
    Remember, there are no stupid questions, just stupid people.

    It didn't work because his form wasn't named form3 which he said.

  24. #24

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    Now why whould you get that idea?? Form3 is the log in form which loads fine. Form 1 is the one that doesnt load. And its because noone told me about useing a module.
    -Rob

  25. #25

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    And also i have kept my mouth shut about you kasracer. I was just grateful that someone was spending time trying to help me out. I looked past your sarcasim and comments but now you are justing being plain mean. I dont care how stupid you think my question is, you never insult people.
    -Rob

  26. #26
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by VBGangsta
    And also i have kept my mouth shut about you kasracer. I was just grateful that someone was spending time trying to help me out. I looked past your sarcasim and comments but now you are justing being plain mean. I dont care how stupid you think my question is, you never insult people.
    It's the internet, it's very common to make fun of people.

    Don't get your panties in a wad

  27. #27

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    Its also common to run into @$$holes even in a learning environment as i see
    -Rob

  28. #28

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    OK Everyone i just want to thank you for all of your time and help, just to let you know i go it to work useing the module. Thanks Again!!!!!!
    -Rob

  29. #29
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by VBGangsta
    OK Everyone i just want to thank you for all of your time and help, just to let you know i go it to work useing the module. Thanks Again!!!!!!
    No Problem

  30. #30
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

  31. #31
    Addicted Member The Phoenix's Avatar
    Join Date
    Aug 2003
    Location
    With my wife
    Posts
    142
    Glad to be of assistance. On behalf of nice guys everywhere, I apologize for the local riff-raff, whoever that might be...
    Take my love
    Take my land
    Take me where I cannot stand
    I don't care, I'm still free
    You can't take the sky from me...

  32. #32

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    One last thing..Everything is working great accpet when I X out the login form it loads the main form making the login form pointless. How do I remove the X out button?
    -Rob

  33. #33
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Originally posted by The Phoenix
    Glad to be of assistance. On behalf of nice guys everywhere, I apologize for the local riff-raff, whoever that might be...
    Well said

  34. #34
    Addicted Member The Phoenix's Avatar
    Join Date
    Aug 2003
    Location
    With my wife
    Posts
    142
    Originally posted by DevGrp
    Well said
    Thank you.

    To remove the "X" button, click on the form in design view, and set the "Control Box" Property to "False". That will remove all control buttons on the top of the form.
    Take my love
    Take my land
    Take me where I cannot stand
    I don't care, I'm still free
    You can't take the sky from me...

  35. #35

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    Ok thanks to that worked, still one problem, if i use ctrl alt delete and kil the login it will load the main form. anyone know how to stop this?
    -Rob

  36. #36
    Addicted Member The Phoenix's Avatar
    Join Date
    Aug 2003
    Location
    With my wife
    Posts
    142
    Although, upon further reflection, I would do this instead: Use "Me.Hide" On the click event of the login form button, and call the next form from there.

    If you just remove the "X" button, and someone were to accidentally open the program, they couldn't close it w/o knowing the password, sine there would only be an "X" button on the main form.

    I've uploaded a new version of my little example program to show you what I mean.

    <EDIT> Yeah, my fault. The module-thing I showed you earlier wasn't the best way t do that. I would highly recommend that you use the method in this program instead. It will solve both problems. Sorry for the inconvinience.
    Attached Files Attached Files
    Last edited by The Phoenix; Oct 4th, 2003 at 09:31 PM.
    Take my love
    Take my land
    Take me where I cannot stand
    I don't care, I'm still free
    You can't take the sky from me...

  37. #37

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    Thank you so much The Phoenix. You have helped me so much. Its really nice of you to write that program it really helped me understand it!! I know I am pushing it with the questions but I have one last thing to do. I need to have so that the custumer only has to put in his password once which is the forst time the program is executed and also only if the password is correct(the first time) . Thanks
    -Rob

  38. #38
    Addicted Member The Phoenix's Avatar
    Join Date
    Aug 2003
    Location
    With my wife
    Posts
    142
    Hey, no preblem. Like I said, this is the first question I ever asked when I started, so it's only fair that I help answer it.

    Give me a few minuites, I have a program that does exactly what you want. I'll comment it more to help you see what it does, and upload it.
    Take my love
    Take my land
    Take me where I cannot stand
    I don't care, I'm still free
    You can't take the sky from me...

  39. #39

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    ok thank you
    -Rob

  40. #40
    Addicted Member The Phoenix's Avatar
    Join Date
    Aug 2003
    Location
    With my wife
    Posts
    142
    Okay, here it is. Sorry it took so long, it gave me trouble there for a minute.

    I hope it helps. I tried to remove most of the things that you wouldn't need, it was a fairly large program.(By my standards at least.) Anyway, look at the comments, and the code. It involves writing to and reading from a text file, but I think you can figure it out.

    The only code you need to see in the main form is at the very bottom, all the rest is in the module, and the login form(frmName).

    If you have any questions, fire away, my code is kinda strange sometimes. (My comments are worse sometimes. )
    Attached Files Attached Files
    Take my love
    Take my land
    Take me where I cannot stand
    I don't care, I'm still free
    You can't take the sky from me...

Page 1 of 3 123 LastLast

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