View Full Version : just wondering how difficult something would be.
John-
03-19-2004, 09:03 PM
i was just wondering how difficult it would be 2 create a program which has 2 textboxs and a command button when you enter something in the first textbox and press the button something appaears in the second textbox(or in a messagebox)
for example
if you entered the number 1 in the first box and pressed enter in the second textbox or in a messagebox the letter a would appear.
or if you entered the number 2 the letter b would appear in the second box.
i am just curious is this difficult?
if not roughly how much code would it involve?
is there any chance of giving a rough idea of how to start it.
Mandy
03-20-2004, 01:55 AM
im sure chess could answer that question for you according to him its not that hard but you never know
John-
03-20-2004, 10:41 AM
yea he seems to know what he is doing, but he uses delphi i think.
Mandy
03-21-2004, 12:17 AM
of course why what did you need help with visual basic ? limp could help you out with that program im sure if he has some spare time
KANE_6969
03-21-2004, 12:29 AM
sounds liek it wouldn't be too hard. planetsourcecode.com would priolly have somethign
Mandy
03-21-2004, 12:47 AM
yeah that is a good site for source codes :p
KANE_6969
03-21-2004, 01:29 AM
why do you need this source it could be altered a lil fromlike pass protection for a program... have a box type in it the pass if wrong it says it in message box.. if right it displays right... could be made to a calculator too prolly... dpends wouldn;t be very hard to make
Mandy
03-21-2004, 10:17 PM
very good advice kane but i would go with a site that has a good rep. This way you know the information your looking for is not altered in any way ;)
KANE_6969
03-22-2004, 04:36 AM
planet source is good site
KANE_6969
03-22-2004, 04:37 AM
and all i;m saying is the structure of theprogram woudl be the same wro all those tyopes of programs
Mandy
03-22-2004, 10:19 PM
no need to go postal right away :p
baloney_mahoney
03-23-2004, 10:49 AM
Private Sub Command1_Click()
Select Case Text1.Text
Case "1"
Text2.Text = "a"
Case "2"
Text2.Text = "b"
Case "3"
Text2.Text = "c"
Case "4"
Text2.Text = "d"
'
'
' etc, etc, etc
'
'
End Select
End Sub
John-
03-23-2004, 03:39 PM
thank you very much. that was very helpful.
all i gotta do to change it to message box is change the text2.text = "a" to msgbox "a"
Mandy
03-23-2004, 09:35 PM
hmmmmmmmmm if you say so :D
John-
03-24-2004, 08:04 PM
what code would i add if i wanted it so that when someone enters a number which isnt in the program it says something like, i do not recognize this number.
baloney_mahoney
03-24-2004, 08:21 PM
Private Sub Command1_Click()
Select Case Text1.Text
Case "1"
Text2.Text = "a" ' or MsgBox = "a"
Case "2"
Text2.Text = "b" ' or MsgBox = "b"
Case "3"
Text2.Text = "c" ' or MsgBox = "c"
Case "4"
Text2.Text = "d" ' or MsgBox = "d"
'
'
' etc, etc, etc
'
'
Case Else
MsgBox "Sorry, your entry cannot be recognized"
End Select
Mandy
03-24-2004, 08:28 PM
very interesting i never seen that before is that a source code for a messenger or something!
baloney_mahoney
03-24-2004, 08:37 PM
VB goes through each Case statement until the value is found. If it isnt found and you have the Case Else statement then VB executes the Else clause. If you dont have it VB just passes through and does nothing.
Select Case Value
Case 1
Do something for value of 1
Case Else
Do something if value not found
End Select
Above is same as below
If Value = 1 Then
Do something if value is 1
Else
Do something if value is not 1
End If
OR...........
Select Case Value
Case 1
Do something for value of 1
End Select
Above is same as below
If Value = 1 Then
Do something if value is 1
End If
Mandy
03-24-2004, 09:01 PM
jesus is this guy smart or what i would give ya an award just for being so smart like the nobel peace prize or something like that you go boy.......................case in point sometimes its better to play smart then to be a jackass take some notes kane
John-
03-24-2004, 10:34 PM
note only smart but helpful, very helpful.
Thanks again.
Mandy
03-24-2004, 11:17 PM
that is so polite of you i should have you over to show my hubby what real manners are !
KANE_6969
03-25-2004, 05:07 PM
its visual basic mandy.
Um i didn;t know if then else statements were that complicated lol LMAO ha
John-
03-25-2004, 07:11 PM
anything in programming is complicated to me, its not just as easy as searching neither because you dont know the words to search for lol.
you try and you end up sticking a 10 word explanation of what you want in google and it comes up with nothing, or you find something completely different to what you wanted.
baloney_mahoney
03-25-2004, 07:40 PM
Originally posted by john123456
anything in programming is complicated to me, its not just as easy as searching neither because you dont know the words to search for lol.
you try and you end up sticking a 10 word explanation of what you want in google and it comes up with nothing, or you find something completely different to what you wanted.
That is probably not the best way to find what you are wanting to know in VB. There is no 'exact answer' per se by searching with an explanation of what you want.
Your best bet is to visit www.vbcode.com (http://www.vbcode.com) or www.1vbstreet.com (http://www.1vbstreet.com) but you can only search for particular subjects and not 'how to do something'. The problem here is that you wont know if you have found the answer until after you have downloaded the source code. Both sites have 'snippits' of some code (you can see the code without downloading it) but you need to keep scrolling through the many, many pages until you come to something that looks helpful.
One day, I wanted to know how to perform a particular function, so I decided that I really had no choise but to go to these two sites and just start from the beginning until I find what I'm looking for. It took about 4 hours before I found the answer. Oh well, that's the way it goes.
I was just wondering why you don't go and buy a book on VB programming. There are many many of them out there (like, I have about 50 or so). You can get a real good book for beginners VB for a few bucks, especially if you buy a somewhat outdated or used one.
John-
03-25-2004, 09:05 PM
thanks for the advice, i joined visualbasicforum.com that is a very good site for beginners, and well it seems alot of advanced programmers often go there for help aswell.
i will certainly try visiting www.1vbstreet.com to have a look about.
i was considering real books the other day, and i guess i could always go to the library to have a little look first before paying any money.
thanks for the help.
Mandy
03-25-2004, 11:00 PM
vb is good but you should have seen the programs ipc is putting together they are simply magnafic
nscopex
04-16-2004, 11:52 PM
Private Sub Text1_Change()
If Text1.Text = "" Then
Text2.Text = ""
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 65
Text2.Text = Text2.Text + "Z"
Case 66
Text2.Text = Text2.Text + "Y"
Case 67
Text2.Text = Text2.Text + "X"
Case 68
Text2.Text = Text2.Text + "W"
Case 69
Text2.Text = Text2.Text + "V"
Case 70
Text2.Text = Text2.Text + "U"
Case 71
Text2.Text = Text2.Text + "T"
Case 72
Text2.Text = Text2.Text + "S"
Case 73
Text2.Text = Text2.Text + "R"
Case 74
Text2.Text = Text2.Text + "Q"
Case 75
Text2.Text = Text2.Text + "P"
Case 76
Text2.Text = Text2.Text + "O"
Case 77
Text2.Text = Text2.Text + "N"
Case 78
Text2.Text = Text2.Text + "M"
Case 79
Text2.Text = Text2.Text + "L"
Case 80
Text2.Text = Text2.Text + "K"
Case 81
Text2.Text = Text2.Text + "J"
Case 82
Text2.Text = Text2.Text + "I"
Case 83
Text2.Text = Text2.Text + "H"
Case 84
Text2.Text = Text2.Text + "G"
Case 85
Text2.Text = Text2.Text + "F"
Case 86
Text2.Text = Text2.Text + "E"
Case 87
Text2.Text = Text2.Text + "D"
Case 88
Text2.Text = Text2.Text + "C"
Case 89
Text2.Text = Text2.Text + "B"
Case 90
Text2.Text = Text2.Text + "A"
Case 97
Text2.Text = Text2.Text + "z"
Case 98
Text2.Text = Text2.Text + "y"
Case 99
Text2.Text = Text2.Text + "x"
Case 100
Text2.Text = Text2.Text + "w"
Case 101
Text2.Text = Text2.Text + "v"
Case 102
Text2.Text = Text2.Text + "u"
Case 103
Text2.Text = Text2.Text + "t"
Case 104
Text2.Text = Text2.Text + "s"
Case 105
Text2.Text = Text2.Text + "r"
Case 106
Text2.Text = Text2.Text + "q"
Case 107
Text2.Text = Text2.Text + "p"
Case 108
Text2.Text = Text2.Text + "o"
Case 109
Text2.Text = Text2.Text + "n"
Case 110
Text2.Text = Text2.Text + "m"
Case 111
Text2.Text = Text2.Text + "l"
Case 112
Text2.Text = Text2.Text + "k"
Case 113
Text2.Text = Text2.Text + "j"
Case 114
Text2.Text = Text2.Text + "i"
Case 115
Text2.Text = Text2.Text + "h"
Case 116
Text2.Text = Text2.Text + "g"
Case 117
Text2.Text = Text2.Text + "f"
Case 118
Text2.Text = Text2.Text + "e"
Case 119
Text2.Text = Text2.Text + "d"
Case 120
Text2.Text = Text2.Text + "c"
Case 121
Text2.Text = Text2.Text + "b"
Case 122
Text2.Text = Text2.Text + "a"
End Select
End Sub
Try thatl, it's more fun :-) Make 2 text boxes of any size on the form keep the names. Couldnt find the "Enter" and "Backspace" ASCII ( They weren't in the Microsoft A+ Certification book ). Have fun.
baloney_mahoney
04-17-2004, 12:50 AM
Enter key is 13 or vbKeyReturn
Backspace key is 8 or vbKeyBack
John-
05-13-2004, 03:18 PM
is there a way of doing it so that it doesnt need to match the entire contents of the textbox for example lets pretend this is my code
Private Sub Command1_Click()
On Error Resume Next
Select Case Text1.Text
Case "123"
Text2.Text = "1"
Case "456"
Text2.Text = "2"
Case "789"
Text2.Text = "3"
Case "987"
Text2.Text = "4"
Case Else
Text2.Text = "Sorry, i dont have that number"
End Select
if i put
dfngdunbguednb
dgnu456vndfjvn
bknabinbngbnnb
into a textbox then in textbox2 the number 2 would appear because 456 was in textbox1
is it possible to do this somehow.
i hope that wasnt to confusing.
baloney_mahoney
05-13-2004, 04:04 PM
You could scan the text in Text1 for the occurance of, say, '456' and if found set Text2 to "2".
But what if the text in Text1 also contains "789"? Then what do yuu want to do? Do you simply scan for the first argument and if found end the matter?
Private Sub Command1_Click()
If InStr(Text1.Text, "123") <> 0 Then Text2.Text = "1" Else
If InStr(Text1.Text, "456") <> 0 Then Text2.Text = "2" Else
If InStr(Text1.Text, "789") <> 0 Then Text2.Text = "3" Else
If InStr(Text1.Text, "987") <> 0 Then Text2.Text = "4" Else
Text2.Text = "Sorry, i dont have that number"
End Sub
John-
05-13-2004, 04:58 PM
Thank you once again.
John-
05-13-2004, 06:41 PM
what would i put so that if none of the numbers (like 123, 456, 789, 987) are in text1.text what would i put so it does nothing at all, rather than giving any output to text2.txt
so it does something like
Private Sub Command1_Click()
If InStr(Text1.Text, "123") <> 0 Then Text2.Text = "1" Else
If InStr(Text1.Text, "456") <> 0 Then Text2.Text = "2" Else
If InStr(Text1.Text, "789") <> 0 Then Text2.Text = "3" Else
If InStr(Text1.Text, "987") <> 0 Then Text2.Text = "4" Else
DoNothing
End Sub
i dont know what code to use so i just put DoNothing as an example of what i mean and hopefully you will understand what i mean.
baloney_mahoney
05-13-2004, 07:11 PM
Remove final Else statement
vBulletin v3.5.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.