Here is my scrpit,, when I try debugging it it keeps doing something stupid saying Conversion from string "" to type 'Double' is not valid. I will make the line it's refering to bold... - Public Class Form1
-
Dim X As String
-
Dim Password, PWord
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
X = InputBox("Please SET your PASSWORD for this application.")
-
If X = vbCancel Then MsgBox("YOU HAVE TO SET A PASSWORD!")
-
Do Until X = vbOKOnly
-
X = InputBox("Please SET your PASSWORD for this application.")
-
If X = vbCancel Then MsgBox("YOU HAVE TO SET A PASSWORD!")
-
If X = vbOKOnly Then Show(Me)
-
Loop
-
End Sub
-
Dim R As String
-
Dim Z As String
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
X = InputBox("Please SET your PASSWORD for this application.")
-
If X = vbCancel Then Exit Sub
-
X = Chr(62)
-
End Sub
-
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
-
R = InputBox("Please Enter your Password")
-
If R = X Then MsgBox("You are cleared for entry!")
-
If R <> X Then MsgBox("Sorry WRONG Password, Nice Try...")
-
End Sub
-
End Class
All that I have under the visual part are two buttons, one to set the password, and another to input it...
I'm trying to make it exit the MSGBOX and return to the INPUTBOX and loop, so that you have to put a value in for it, or it won't continue, SOMEONE PLZ help me (and if you attempt to explain it to me please try to explain it to me from scratch, because I have no clue what I'm doing and I'm new at this.)
THANX ALOT TO ANYONE WHO TRYS HELPING ME!!
14 1731
At first glance, I'd say variable X needs to be numeric. The MsgBox function returns a number, not a string.
Here is my scrpit,, when I try debugging it it keeps doing something stupid saying Conversion from string "" to type 'Double' is not valid. I will make the line it's refering to bold...
Public Class Form1
Dim X As String
Dim Password, PWord
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
X = InputBox("Please SET your PASSWORD for this application.")
If X = vbCancel Then MsgBox("YOU HAVE TO SET A PASSWORD!")
Do Until X = vbOKOnly
X = InputBox("Please SET your PASSWORD for this application.") If X = vbCancel Then MsgBox("YOU HAVE TO SET A PASSWORD!")
If X = vbOKOnly Then Show(Me)
Loop
End Sub
Dim R As String
Dim Z As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
X = InputBox("Please SET your PASSWORD for this application.")
If X = vbCancel Then Exit Sub
X = Chr(62)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
R = InputBox("Please Enter your Password")
If R = X Then MsgBox("You are cleared for entry!")
If R <> X Then MsgBox("Sorry WRONG Password, Nice Try...")
End Sub
End Class
All that I have under the visual part are two buttons, one to set the password, and another to input it...
I'm trying to make it exit the MSGBOX and return to the INPUTBOX and loop, so that you have to put a value in for it, or it won't continue, SOMEONE PLZ help me (and if you attempt to explain it to me please try to explain it to me from scratch, because I have no clue what I'm doing and I'm new at this.)
THANX ALOT TO ANYONE WHO TRYS HELPING ME!!
Reply :Please define your variable x as integer b/c VBCancel returns the neumeric value which is 3 which is for cancel button
Conversion from string "SET" to type 'Integer' is not valid. is the reply I get when I "dim X as integer"
Whoops! You've got a bit of a mess there. You're trying to use the same variable to accept the return value from InputBox, which returns a string, and MsgBox, which returns a number (probably Integer).
I recommend using separate variables. I also recommend not using the InputBox function, but that's another story.
So how would I do that?
And is there a way to make another form on the same program and then link to that form, if so, how?
Thanx!
So how would I do that?
How would you do what?
If you mean create separate variables, simply declare a String variable and an Integer variable (with different names, obviously). Use each of them where appropriate, rather than trying to use the one string for everything.
And is there a way to make another form on the same program and then link to that form, if so, how?
to create a new form, you just do whatever you did to create the first one. A VB project can contain a huge number of forms. (I can't tell you the specifics of how to create a form, as I work with a much older version and things have changed.)
As for "linking" them, it's just a question of what you want to do with them.
Yea, i get that, but how does the program know that the INTEGER (Dimed as "X" lets say) is connected to the INPUTBOX (lets say "Y" that was Dimed as a String) That's what I don't get how to do... Because if i put Dim X as integer and Dim Y as string then i would put Y = inputbox("blah......") but how does it know that X is the integer for the Y inputbox? I can't get it to do that
Yea, i get that, but how does the program know that the INTEGER (Dimed as "X" lets say) is connected to the INPUTBOX (lets say "Y" that was Dimed as a String) That's what I don't get how to do... Because if i put Dim X as integer and Dim Y as string then i would put Y = inputbox("blah......") but how does it know that X is the integer for the Y inputbox? I can't get it to do that
From the look of your code it looks like you are using vb08 or vb2k5
Any way.....forget about input boxes........
You Should create your own input box....I suggest a login form.....
Go to add new items.....
Add new form
Login form.......
Customize it.........
Use the code i post in next post....
- Public Class Form1
-
Dim X As long
-
'This is the command to use on the OK...button
-
Private Sub FormLogin_OK(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Formlogin.click
-
If Textbox1.text = "" or isnumeric(Textbox1.text) = False then
-
-
MsgBox("YOU HAVE TO SET A NUMERIC PASSWORD!")
-
Textbox1.Focus
-
Exit Sub
-
-
End if
-
-
X= Textbox1.text ' ie the textbox that recieves the password
-
Mainform.show 'Change main form with the form you want to load
-
me.hide
-
-
End sub
-
-
'I dont think this is advasiable it prevents exit from the program
-
-
Private Sub FormLogin_Cancel(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Formlogin.cancel
-
MsgBox("YOU HAVE TO SET A PASSWORD!")
-
Textbox1.Focus 'ie the textbox that recieves the password
-
-
End sub
-
-
'instead of above I would use.......
-
-
Private Sub FormLogin_Cancel(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Formlogin.cancel
-
-
Me.close
-
-
End sub
-
End Class
Thanx man, you're greek ha? Euxaristw re file... 8a to dokhmasw!
Thanx man, you're greek ha? Euxaristw re file... 8a to dokhmasw!
Barakalw...... No problem
Barakalw...... No problem
Come on people, English only or I'll have to start deleting posts.
If you want to chat in Greek, please do so via Private Message. The posting guidelines require English in the forums.
Yea, i get that, but how does the program know that the INTEGER (Dimed as "X" lets say) is connected to the INPUTBOX (lets say "Y" that was Dimed as a String) That's what I don't get how to do... Because if i put Dim X as integer and Dim Y as string then i would put Y = inputbox("blah......") but how does it know that X is the integer for the Y inputbox? I can't get it to do that
Why would you expect VB to "know" which variable is intended for what purpose?
You use the Integer where an Integer is required, and the String where a String is required.
MsgBox returns an Integer, so you use X there. InputBox returns a String, so you use Y. There's no connection between the two.
sorry killer...................................
Sign in to post your reply or Sign up for a free account.
Similar topics
by: kaiwing18 |
last post by:
Hi,
I have a simple java server program, i want to ask how can i output a
simple HTML page of error message, without calling a html file. That
means i want to type HTML codes in the program...
|
by: cat_dog_ass |
last post by:
I am used to programming in DOS mode via Borland C++. I would now like
to create programs for the Windows envirinment. Is it absoultely
necessary to use Visual C++ to do this? Are there other tools...
|
by: Robert Shull |
last post by:
I am taking a class in C++. We are creating console
applications using Visual C++.NET 2002. The assignment is
to create a "mailing label" using information coded into
the program. My code looks...
|
by: glenn |
last post by:
I keep reading all sorts of books on VS that keep telling me to click on
Tools/Visual Studio Command prompt to run this program or that program.
However, I do not have such a menu choice. Where is...
|
by: Thomas Johnson |
last post by:
I am trying to find out how to access the VS 2003 .Net command prompt. I
am trying to execute the 'csc' command against a module but have no idea
where to find the command prompt. Here's a stupid...
|
by: Arthur van Dorp |
last post by:
Hi all
This is a bit off topic but I don't know where else to ask (please tell
me if you know). I'm going to build a web application. The choice of the
underlying database wasn't difficult....
|
by: Jwolf |
last post by:
I have .net 2002 edu version and when it installed there was a shortcut to
the .net command prompt. My CLR disk is scratched so I can't reinstall and
so I just downloaded express.
I dont know...
|
by: srp8982 |
last post by:
hello friends,
I need your help in regards with socket programming in c.
If anybody knows it plz help me out.
you have to write a program for a TCP client.
the problem is to to write a program...
|
by: munugalaramesh |
last post by:
How to clear mysql command prompt as cls in normal command prompt
|
by: =?Utf-8?B?Sm9obg==?= |
last post by:
Hi all,
I am new to .net technologies.
ASP.NET supports socket programming like send/receive in c or c++?
I am developing web-site application in asp.net and code behind is Visual
C#. In...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |