Latac
09-08-2003, 08:30 PM
Simple newbie question:
How do I count the amount of chars in a text box?
thanks.
How do I count the amount of chars in a text box?
thanks.
CountLatac 09-08-2003, 08:30 PM Simple newbie question: How do I count the amount of chars in a text box? thanks. MikeJ 09-08-2003, 08:33 PM Len() will return a number value of the characters in a string (or textbox). ~Mike Latac 09-08-2003, 10:23 PM IT displays pop up box "moo" when I enter correct serial number.. any idea why? Option Explicit Private Sub Command1_Click() Dim box1 As String Dim box2 As String If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Then MsgBox "Please fill in all the boxes", , "Error" Exit Sub End If If Text2.Text = "ABX" Then Form2.Label4.Caption = "1" Form2.Frame1.Visible = True Else End If If Text2.Text = "ACZ" Then Form2.Label4.Caption = "2" Form2.Frame2.Visible = True Else End If If Text2.Text = "BJD" Then Form2.Label4.Caption = "3" Form2.Frame3.Visible = True Else End If If Text2.Text = "CNR" Then Form2.Label4.Caption = "4" Form2.Frame4.Visible = True Else End If If Text2.Text = "MKF" Then Form2.Label4.Caption = "5" Form2.Frame5.Visible = True Else End If If Text4.Text = "014" Then Form2.Show Else MsgBox "moo" End If End Sub plz dont' judge the code.. I know its a mess.. DirectAllX 09-08-2003, 10:26 PM which sub the code is in?? Latac 09-08-2003, 10:28 PM Command1 DirectAllX 09-08-2003, 10:46 PM maybe there's a problem with the numbers comparision you know, you have "014", so you could try: If Val(Form1.Text4) = 014 Then Form2.Show Else MsgBox "moo" End If BlueDragon 09-08-2003, 11:12 PM Instead of a simple Else, try using ElseIf like this: If Text4.Text = "014" Then Form2.Show ElseIf Text4.Text <> "014" then MsgBox "moo" End If Latac 09-09-2003, 08:53 AM still displays moo as if it was wrong..:( help!!!!!! Thinker 09-09-2003, 09:01 AM Any chance you are typing in a capital letter O rather than the number 0? Latac 09-09-2003, 09:08 AM possitive heres my current code: Option Explicit Private Sub Command1_Click() Dim box1 As String Dim box2 As String If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Then MsgBox "Please fill in all the boxes", , "Error" Exit Sub End If '1111 If Text2.Text = "ABX" Then Form2.Label4.Caption = "1" Form2.Frame1.Visible = True Else End If '2 If Text2.Text = "ACZ" Then Form2.Label4.Caption = "2" Form2.Frame2.Visible = True Else End If '3 If Text2.Text = "BJD" Then Form2.Label4.Caption = "3" Form2.Frame3.Visible = True Else End If '4 If Text2.Text = "CNR" Then Form2.Label4.Caption = "4" Form2.Frame4.Visible = True Else End If '5 If Text2.Text = "MKF" Then Form2.Label4.Caption = "5" Form2.Frame5.Visible = True Else End If '6 If Val(Form1.Text4.Text) = "014" Then Form2.Show ElseIf Text4.Text <> "014" Then MsgBox " moo" Exit Sub End If '7 End Sub bk2003 09-09-2003, 09:28 AM Hi, Are you sure you have typed the right name of the textbox?? Anyway, the VAL(text) should return a value, right? So you don't need that. But try a little debuging example: If Text4.Text = "014" Then Form2.Show Else msgbox text4.text 'Insert something like this for debuging MsgBox "moo" End If End Sub This maybe helps you a little bit... /BK Latac 09-09-2003, 09:35 AM nothing works * * * is going on.. whats so wrong about this: If Text2.Text = "MKF" & Text4.Text = "014" Then Form2.Show Form2.Label4.Caption = "5" Form2.Frame5.Visible = True Else MsgBox "Inccorect serial number", , "Error" End If Thinker 09-09-2003, 09:38 AM & is the String concatenation operator. You need And there. Latac 09-09-2003, 09:53 AM Edit: thanks thinker and everyone else for your great help! works now! Thinker 09-09-2003, 09:56 AM No, no one can tell you what is wrong because we can't see what is actually in your textboxes. What is really wrong is that you don't know how to debug your own code. This tutorial will teach you what you need to know to solve this problem... http://www.visualbasicforum.com/showthread.php?threadid=9415 |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum