Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 9th, 2004, 12:33 AM
Authorized User
 
Join Date: Jul 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can't stop inputbox from displaying

Below is a sub I wrote to ask for a password if necessary. If ASC=91 it displays MsgBox(OK) but then it goes rite on and displays the input box when it shouldn't. This is driving me nuts. I've tried more ways to block it and the 2 Msgbox's show the values correct, and it still displays it. What is My Problem?

Private Sub Command6_Click()
 Dim X As Integer
 Dim Msg$
 Regg% = 6
 If Asc(OwnerName(6)) = 91 Then
  CR$ = Chr$(13) + Chr$(10)
  Msg$ = "To Continue You Must OK !" + CR$ + " Then Set - Up To" + CR$ + " Configure Your Register Slot"
  X = MsgBox(Msg$, 1, "Register 6", HelpFile, Context)
  Form2.Hide
  Load Form3
  Form3.Show
End If
     m = MsgBox("Cnf & R=" + Cnf(Regg%).R) 1******
     m = MsgBox(" OwnName= " + OwnerName(6)) 2******
If OwnerName(6) = "[" Then GoTo LineA
 If Asc(OwnerName(6)) <> 91 And Cnf(Regg%).R <> "NONENONE" Or Cnf(Regg%).S <> "NONENONE" Or Cnf(Regg%).R <> "" Or Cnf(Regg%).S <> "" Then
   Q$ = InputBox$("Enter Password Now !!", " PASSWORD FOR REGISTER No: " + Str$(Regg%))
   If Q$ = "|" Then
      ShowPassword
   End If
   If Q$ = Cnf(Regg%).R Or Q$ = Cnf(Regg%).S Then
      Form2.Hide
      Load Form3
      Form3.Show
      Else
      If Q$ <> "|" Then
         X = MsgBox("InValid Password")
      End If
   End If
 End If

 If Cnf(Regg%).R = "NONENONE" Or Cnf(Regg%).S = "NONENONE" Then
   Form2.Hide
   Load Form3
   Form3.Show
 End If
LineA:
End Sub




It took me 74 years to get this stupid!
__________________
It took me 74 years to get this stupid!
 
Old July 9th, 2004, 07:58 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My first guess is that you need to put parenthesis around the and clause. It is best to do so as it clearly deliniates the logic that you are trying to achieve. I have gotten mixed results when not doing so.

Just some pointers (I hope these are welcome)

1. Name your variables meaningfully. X, Y, Z etc. does not make the code readable and it is easy to forget their purpose.

2. Get rid of the GoTo. It is bad style and once again makes the code tough to read. Exit Sub will do the same as the goto in this case.

3. I am unsure if this applies as I am not sure if some these variables are declared outside the function, but always use option explicit. Forcing yourself to declare variables first save a lot of grief in the long run.

4. Put in error handling.

Yehuda
 
Old July 11th, 2004, 02:06 PM
Authorized User
 
Join Date: Jul 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank You!

It took me 74 years to get this stupid!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop button won't stop loop JDShaffer Visual Basic 2008 Essentials 3 May 23rd, 2008 03:22 PM
Retreiving value from InputBox maniatis1 Classic ASP Professional 1 January 4th, 2007 03:36 PM
Format inputbox jesseleon Access VBA 2 October 5th, 2005 03:14 PM
Inputbox and Formulas bahachin Excel VBA 3 February 17th, 2005 01:39 AM
InputBox Misbehaving bph Access 10 March 4th, 2004 01:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.