473,386 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

I'm New to VB and Programming - I've only used Command Prompt

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...

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Dim X As String
  3.     Dim Password, PWord
  4.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  5.         X = InputBox("Please SET your PASSWORD for this application.")
  6.         If X = vbCancel Then MsgBox("YOU HAVE TO SET A PASSWORD!")
  7.         Do Until X = vbOKOnly
  8.             X = InputBox("Please SET your PASSWORD for this application.")
  9.             If X = vbCancel Then  MsgBox("YOU HAVE TO SET A PASSWORD!")
  10.             If X = vbOKOnly Then Show(Me)
  11.         Loop
  12.     End Sub
  13.     Dim R As String
  14.     Dim Z As String
  15.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  16.         X = InputBox("Please SET your PASSWORD for this application.")
  17.         If X = vbCancel Then Exit Sub
  18.         X = Chr(62)
  19.     End Sub
  20.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  21.         R = InputBox("Please Enter your Password")
  22.         If R = X Then MsgBox("You are cleared for entry!")
  23.         If R <> X Then MsgBox("Sorry WRONG Password, Nice Try...")
  24.     End Sub
  25. 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!!
Jan 27 '08 #1
14 1731
Killer42
8,435 Expert 8TB
At first glance, I'd say variable X needs to be numeric. The MsgBox function returns a number, not a string.
Jan 28 '08 #2
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
Jan 28 '08 #3
Conversion from string "SET" to type 'Integer' is not valid. is the reply I get when I "dim X as integer"
Jan 28 '08 #4
Killer42
8,435 Expert 8TB
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.
Jan 28 '08 #5
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!
Jan 28 '08 #6
Killer42
8,435 Expert 8TB
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.
Jan 29 '08 #7
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
Jan 29 '08 #8
daniel aristidou
491 256MB
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....
Jan 29 '08 #9
daniel aristidou
491 256MB
Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2. Dim X As long
  3. 'This is the command to use on the OK...button 
  4. Private Sub FormLogin_OK(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Formlogin.click
  5. If Textbox1.text = "" or isnumeric(Textbox1.text) = False then
  6.  
  7. MsgBox("YOU HAVE TO SET A NUMERIC PASSWORD!")
  8. Textbox1.Focus
  9. Exit Sub
  10.  
  11. End if
  12.  
  13. X= Textbox1.text ' ie the textbox that recieves the password
  14. Mainform.show 'Change main form with the form you want to load
  15. me.hide 
  16.  
  17. End sub
  18.  
  19. 'I dont think this is advasiable it prevents exit from the program
  20.  
  21. Private Sub FormLogin_Cancel(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Formlogin.cancel
  22. MsgBox("YOU HAVE TO SET A PASSWORD!")
  23. Textbox1.Focus 'ie the textbox that recieves the password
  24.  
  25. End sub
  26.  
  27. 'instead of above I would use.......
  28.  
  29. Private Sub FormLogin_Cancel(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Formlogin.cancel
  30.  
  31. Me.close
  32.  
  33. End sub
  34. End Class 
Jan 29 '08 #10
Thanx man, you're greek ha? Euxaristw re file... 8a to dokhmasw!
Jan 29 '08 #11
daniel aristidou
491 256MB
Thanx man, you're greek ha? Euxaristw re file... 8a to dokhmasw!
Barakalw...... No problem
Jan 29 '08 #12
Killer42
8,435 Expert 8TB
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.
Jan 29 '08 #13
Killer42
8,435 Expert 8TB
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.
Jan 29 '08 #14
daniel aristidou
491 256MB
sorry killer...................................
Jan 30 '08 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

5
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...
32
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...
4
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...
4
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...
4
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...
17
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....
6
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...
1
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...
3
by: munugalaramesh | last post by:
How to clear mysql command prompt as cls in normal command prompt
8
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
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...
0
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
0
BarryA
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...
0
marktang
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,...
0
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...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.