I'm new to VB, a newbie could even help me.
I want the user to see a new screen after the the person enters in a password and presses enter. Simply put, I want to clear that form and have a new one show up so I can go from there. I've got the (basic)password part down but what should I do from there?
Current code: (for cmdEnter_Click() )
_______________________________________
Private Sub cmdEnter_Click()
If txt1.Text = "" Then
MsgBox "You must enter the password.", vbCritical
Exit Sub
End If
If txt1.Text = "Xpass" Then
MsgBox "You are logged in!", vbExclamation
'SHOULD CODE GO HERE?
Exit Sub
Else
MsgBox "Please enter the correct password!", vbCritical
End If
End Sub
________________________________
Also, how do I change this text? :
![]()
+ Reply to Thread
Results 1 to 30 of 31
-
-
The text in the form frame is a property. "name" maybe ?
Do you want to change it at design time or run time ?
most things have "visible" property
It's been a while , What generally do you want to do.?
Ok I just made a 2 form program
form1 has a button that toggles the visibility of form2
Private Sub Command1_Click()
Form2.Visible = Not Form2.Visible
End Sub -
To use a custom title for your message box:
MsgBox "You are logged in!", vbExclamation, "Custom Title goes here"
Now that was easy, wasn't itOpen WIDE for Chunky!!! -
Create another form for what you want the user to see after entering the correct password (let's call it frmCorrect) and use the .Show command inside your if statement.
If txt1.Text = "Xpass" Then
MsgBox "You are logged in!", vbExclamation
frmCorrect.Show
Exit Sub
Else
MsgBox "Please enter the correct password!", vbCritical
End If
You can use the .Hide command or "Unload Me" to close your first form:
frmName.Hide 'Hides form "frmName" keeping the value of any controls on the form
Unload Me 'Unloads the form, clearing all values of controlsOpen WIDE for Chunky!!! -
Try this:
1) Create a project.
2) In the properties set the Form Visible to False
3) Add for event this in load:
Private Sub Form_Load()
Dim szPassword As String
szPassword = InputBox("Enter Password", "Security")
If (szPassword = "FRED") Then
'-Unlock Allow to fall through
Me.Visible = True
Else
'- Beep wrong answer! It stops here!
Me.Visible = True
End
End If
End Sub
This will hid the Form. Ask the user a queston. IF correct show the Form else kill the program.
Could do this instead of the If/endif:
------- Start of code
dim iRetrys as integer
dim bFinished as boolean
iRetries = 5 ' Good even human number for wrong trys
bFinished = false
while ( not bFinished )
szPassword = InputBox("Enter Password", "Security")
If (szPassword = "FRED") Then
'-Unlock Allow to fall through
bFinished = true
Else
'- Beep wrong answer! It stops here!
iRetries = iRetries - 1
if ( iRetries <= 0 ) then
bFinished = true
End if
End If
wend
'- See if any chances are left
if ( iRetries > 0 ) then
me.visible = true ' Its alive! Activate main Form!
else
end ' Its dead Jim
endif
---------------- End of code
Be nice if we had tabs for this.
PS: Made goof of iRetry instead of iRetries at test! -
Instead of a msgbox you can use a form to show a msg. Just set the borderstyle to 0 (none) and blank the caption. The form will display without a title bar when you make it visible. All you need to do is set the background color to whatever you like and use a label with a transparent background to write your msg. If you use a timer control you can have the "successful logon msg display for a set time then hide it or unload when time expires and then set your next form's property to visible.
P.s. Just like any other form, you can position this "msg form" anywhere on the screen. The beauty of this method is that you can add color and graphics and all kinds of effects to your custom message. -
Man,
Get a book, they are for sale in every bookstore. VB is getting obsolete. -
C# is a good choice. If you have visual studio it's as easier as VB and way more powerful. You can get the compiler for free.
But it's better to get a book and start from there. Get a used one! -
Hum I though it was VB .net that was dead out of the starting gate? Vb is usualy used for quicky stuff.
C# is nice but not standard on anything but MS world. -
Microsoft and free usualy dont go together.
Current price of C# is around 100 dollars for one user. -
And what do you need with that to actually do anything.
I have a 2 yr old .NET installation from my job.
I don't know what it cost but it came on 2 DVDs
Can you get a C# with a VB-like IDE ? or is it the whole .NET thing.
They ruined VB . Actually they fixed it but , they destroyed a lot of
previous work. -
You could upgrad old code through different VB untill .net.
Though that C# was VB style ontop of C/C++. Dont use it. VC 6 and VB6 handles most of my clients needs.
Cant remember but the full package is expensive. -
Though that C# was VB style ontop of C/C++. Dont use it. VC 6 and VB6 handles most of my clients needs.
Can you do real OOP in VB6? threading? advance File System operations? Man, u need to read more. C# is easier than C++ but a little more difficult than VB6.
The only problem is getting Visual studio, but u can use some free editors
Check this http://www.gotdotnet.com/ -> good site. -
The real key thing is "How to Program". Using any programming language is a small matter. Using a libarary or concept is also a small matter. Some are better some are worse but knowing "How to Program" or should say "thinking" is the key. Like the difference between a cook and a chef.
Getting back on subject:
g_shocker182. How did it turn out?Did you get the task done? Or are you having other problems?
-
Originally Posted by NightWing
Thanks! -
By the way, what do you guys use your programmer experience for? I find that C++ stuff, c# or whatever incredibly diifficult to understand..like learning Chinese when all you know is Basque.
-
Glad you got your problem solved!
That is the main thing!
Have done just about everthing I guess. From mutiple business, games, telementry, databases and even Military programs for various clients over the decades.
C and its varrants are a bit strange.It takes the best of a high level language with the power of an assembler.
-
Hi guys. I was searching around, and finally came across this topic,
though its old. I thought I'd use it since the title says it all.
Maybe I (and others) will use it for future inquiries.
Anyways.
Probably a really dumb question.. but its been a long time since I
used VB for much anything these days. Some things you do forget,
though I vaugly remember this one.. don't know the purpose of this one.
Some examples:
BUFFER = String(256, Chr$(65))
strFileTitle = String(256, 0)
What exactly is the above doing ??
So that I can create a Delphi equivalent, please.
Thanks.
-vhelp 4079 -
Originally Posted by g_shocker182
There is a lot of interest in PROLOG used mostly in the SW test area.
The question of how to learn to program is a diffcult one to answer. In todays world most the detail theory behind programing will not be covered until grad school.
With that said I am pleased that you are trying to learn. VB is a good start. There are many books on Comp Science that will help fill in the theory.
If you have any other question I will be glad to try and answer them. -
If memory serves the first creates a Variant named BUFFER containing 256 lower case a's. The second creates a Variant named strFileTitle contaiing 256 null characters, but will probably just return Null.
"Shut up Wesley!" -- Captain Jean-Luc Picard
Buy My Books -
sorry jameshgross but I have to... Hope they teach reading skills with C and C++.......
Don't get upset it's just a joke. I too was caught answering a very old post after someone resurrected it many years later.
@vhelp
BUFFER = String(256, Chr$(65))
strFileTitle = String(256, 0)
Looks like the programmer is trying to load a string variable called BUFFER with 256 "A" since CHR(65) is the code for "A". He could have also just used "65".
For the strFileTitle = String(256, 0) , Written this way it looks like he is blanking the strFileTitle variable with nulls. If he had put "0" then it would have written zeroes.
edit
@gadgetguy ... too busy laughing while writing and eating that you posted while I was away and before I pushed send... same thought -
Actually those would be uppercase 'A's. Lowercase 'a' is 97.
EDIT: Whoops, gll99 pointed out the 'A' thing while I was posting. -
Ok. Thanks guys. I have another question. Get your thinking
caps on for this one, cause it's a VB -to- Delphi porting question..
-vhelp 4080 -
Originally Posted by jameshgross
I am also a professional programmer (just not old enough to have over 30 years experience :P ) We are a small company, but we also have over $10M in annual sales. All of our products are developed in C++, C#, and JAVA (it's not just for "script kiddies").
That said, personal preferences in programming languages are much like the "taste great/less filling" argument. Some languages lend themselves better to certain tasks though. As jameshgross points out, it is the science behind the code development that is more important. Without good fundamentals, you can't hope to produce anything more than marginal programs regardless of what language you use. -
OK so my memory isn't as good as it used to be.
"Shut up Wesley!" -- Captain Jean-Luc Picard
Buy My Books -
Ok. Here's the question w/ code snips. It's a TWO Question follow-up,
post.
First, I'm not sure what this: Ret& is. But, I think that it acts
as a pointer ?? I've seen some VB code usage as:
Code:ie, 1 - DIM Ret&
Code:ie, 2 - ret& = modMAPI.MAPILogoff(MAPISess, 0, 0, 0)
Code:ie, 3 - Dim ret As Long If Not ret = MAPI_E_NO_MESSAGES Then AnzahlNachrichten = AnzahlNachrichten + 1 End If
Ok. Sometimes, I see it as ret& and other times, as ret, without "&"
following it. So, I get confused and am not sure how to port to Delphi,
correctly.
VB CODE:
Code:Private Declare Function ReadFile Lib "kernel32" ( _ ByVal hFile As Long, _ ByVal lpBuffer As String, _ ByVal nNumberOfBytesToRead As Long, _ lpNumberOfBytesRead As Long, _ byval lpOverlapped As Any) As Long
DELPHI PORT:
Code:Function ReadFile( var hFile: longint; var lpBuffer: string; var nNumberOfBytesToRead: longint; lpNumberOfBytesRead: Longint; var lpOverlapped): longint; cdecl; external 'kernel32.dll'
I'm not sure I remember exactly: ByVal 's use, and the Delphi equivalent usage.
Also, there is the: ByVal lpOverlapped as Any. This seems to be a Variant, and
I think the Delphi equivalent, is Untyped (or, unkown value of any type) but I'm
not sure. So, I wrote in: var lpOverlapped, as my solution to the assumed,
VB Variant port to Delphi.
Please correct me if my Port is setup wrong, thanks guys.
-vhelp 4081
Similar Threads
-
Calling MediaInfo from Visual Basic to et video info
By SearchQuality in forum ProgrammingReplies: 18Last Post: 2nd Nov 2011, 06:36 -
visual basic code
By kudoshinichi in forum ProgrammingReplies: 1Last Post: 21st Jan 2009, 08:30 -
PHP code used to generate code for Avysinth join mov and avi files
By lindylex in forum User guidesReplies: 0Last Post: 19th Sep 2008, 03:37 -
Programming FFMPEG (Visual Basic)
By Ace-Of-Spades in forum ProgrammingReplies: 4Last Post: 9th Oct 2007, 06:18