PDA

View Full Version : سوال: ساختن پلاک ماشین در یک textbox



karim orooji
دوشنبه 21 بهمن 1387, 19:54 عصر
با سلام به دوستان
من vb.net کار میکنم تازه کارم
مخوام در یک textbox بتونم ابتدا دو کاراکتر عددی سپس کاراکتر سومی فقط حرفی تایپ شود و دو کارکتر بعد بصورت عدد
شبیه ساز پلاک ماشین
عکس ضمیمه شده است
از دوستان گلم خواهش میکنم که به صورت کامل برای من شرح دهند:عصبانی++:

sari-1369
سه شنبه 22 بهمن 1387, 00:41 صبح
سلام دوست من به نظر من بهتره از 3 تا تکس باکس استفاده کنی . این کدو ببین . ( فایل پروژه رو هم ضمیمه کردم ) .

نکته : فقط عدد گرفتن رو واست درست کردم . اما برای اینکه در کاراکترسوم فقط حرف بگیره کدشو ندارم . که اونم فقط کافیه کد های اسکی حروف اعداد رو بدونی و هرچی غیر اونا رو برگشت بدی .




Public Class Form1


Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
If TextBox2.TextLength = 1 Then TextBox3.Focus()
End Sub

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(Keys.Enter) Then
SendKeys.Send("{Tab}")
End If

If Not IsNumeric(e.KeyChar) And e.KeyChar <> Convert.ToChar(Keys.Back) And e.KeyChar <> Convert.ToChar(Keys.Delete) Then
e.Handled = True
End If
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.TextLength = 2 Then TextBox2.Focus()
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.MaxLength = 2
TextBox2.MaxLength = 1
TextBox3.MaxLength = 2
End Sub

Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
If e.KeyChar = Chr(Keys.Enter) Then
SendKeys.Send("{Tab}")
End If

If Not IsNumeric(e.KeyChar) And e.KeyChar <> Convert.ToChar(Keys.Back) And e.KeyChar <> Convert.ToChar(Keys.Delete) Then
e.Handled = True
End If
End Sub

End Class

mnodehi
پنج شنبه 09 آبان 1392, 15:19 عصر
بهترین کار استفاده از کاراکترهای تعیین جهت قراردادن کاراکترها است من تو لینک زیر دیدم متن اون و مثال فارسی شدش رو هم اینجا کپی می کنم.

http://stackoverflow.com/questions/6594915/unicode-strings-in-net-with-hebrew-letters-and-numbers


The unicode characters "RTL mark" (U+200F) and "LTR mark" (U+200E) were created precisely for this purpose.

In your example, simply place an LTR mark after the Hebrew character, and the numbers will then be displayed to the right of the Hebrew character, as you wish.

So your code would be adjusted as follows:

string A = "123";
string AA = "ب";
string LTRMark = "\u200E";
string B = "45";
string AB = A + LTRMark + AA + LTRMark + B;
textBox2.Text = AB;