Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27569

Masked TextBox

$
0
0
Hello programmers, I have one problem. I have two Textboxes (GSM and Telefon) with Mask. So I whant, when is one empty (e.g. Telefon, it mean, that I don't put no numbers in this textbox) that is writen on paper only one that is full (e.g. GSM).

Here is code that I use:

Code:

If (GSMTextBox.Text.Length = 15 AndAlso TelefonTextBox.Text.Length = 15) Then
            e.Graphics.DrawString(Label19.Text, font1, Brushes.Black, e.MarginBounds.Left, 217)
            e.Graphics.DrawString(GSMTextBox.Text, font1, Brushes.Black, 145, 217)
            e.Graphics.DrawString(Label20.Text, font1, Brushes.Black, 267, 217)
            e.Graphics.DrawString(TelefonTextBox.Text, font1, Brushes.Black, 328, 217)
        ElseIf (GSMTextBox.Text.Length = 15 AndAlso TelefonTextBox.Text.Length < 1) Then
            e.Graphics.DrawString(Label19.Text, font1, Brushes.Black, e.MarginBounds.Left, 217)
            e.Graphics.DrawString(GSMTextBox.Text, font1, Brushes.Black, 145, 217)
            e.Graphics.DrawString(Label20.Text, font1, Brushes.White, 267, 217)
            e.Graphics.DrawString(TelefonTextBox.Text, font1, Brushes.White, 328, 217)
        ElseIf (GSMTextBox.Text.Length < 1 AndAlso TelefonTextBox.Text.Length = 15) Then
            e.Graphics.DrawString(Label20.Text, font1, Brushes.Black, e.MarginBounds.Left, 217)
            e.Graphics.DrawString(TelefonTextBox.Text, font1, Brushes.Black, 145, 217)
            e.Graphics.DrawString(Label19.Text, font1, Brushes.White, 267, 217)
            e.Graphics.DrawString(GSMTextBox.Text, font1, Brushes.White, 328, 217)
        ElseIf (GSMTextBox.Text.Length < 1 AndAlso TelefonTextBox.Text.Length < 1) Then
            e.Graphics.DrawString(Label20.Text, font1, Brushes.White, e.MarginBounds.Left, 217)
            e.Graphics.DrawString(TelefonTextBox.Text, font1, Brushes.White, 145, 217)
            e.Graphics.DrawString(Label19.Text, font1, Brushes.White, 267, 217)
            e.Graphics.DrawString(GSMTextBox.Text, font1, Brushes.White, 328, 217)
        End If

Problem is, that Masked Textbox will always be full. If you see in code above GSM and Telefon are fields with length of 15 characters. So if I dont put number in Textbox e.g. Telefon, field will be empty - visualy, in truth there is still 15 characters in. Here is picture:

Name:  masktextbox.JPG
Views: 67
Size:  10.0 KB (This field is from database, Mask Textbox is in other form, where you put number and save it to database).

Thanks to all for any ideas.
Attached Images
 

Viewing all articles
Browse latest Browse all 27569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>