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:
Function GetSerialNumber(ByRef strDrive As String) As Integer
Dim SerialNum As Integer
Dim Res As Integer
Dim Temp1 As String
Dim Temp2 As String
'
Temp1 = New String(Chr(0), 255)
Temp2 = New String(Chr(0), 255)
Res = GetVolumeInformation(strDrive, Temp1, Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2))
GetSerialNumber = SerialNum
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
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
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
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:
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???
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:
If TextBox1.Text = 2 Then
frmform1.Show()
form3.close()
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
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!!
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...
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).
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.
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.
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.
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.
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.
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.
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!!!!!!
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?
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...
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...
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.
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...
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
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. )
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...