2. چون شما به queue اشاره کردین، کد رو هم برای queue و هم برای list نوشتم (با // جدا کردم) و انتخابش رو بعهده خودتون میگذارم.
فقط در حال کلی list قابلیت انعطاف بیشتری داره و ارجح هست، در این مسئله خاص تفاوتی نداره.
dim q as new queue(of string) // dim list as new list(of string)
sub form_keypress
if not char.isletterordigit(e.keychar) then exit sub
select case q.count // list.count
case 0 ' check for first key
if e.keychar>="1" andalso e.keychar<="9" then
q.enqueue(e.keychar) // list.add(e.keychar)
else
q.clear // list.clear
end if
case 1 ' check for second key
if char.isletterordigit(e.keychar) then
q.enqueue(e.keychar) // list.add(e.keychar)
if show_form(join(q.toarray // list.toarray, string.empty)) then
q.clear // list.clear
else
if char.isletter(e.keychar) orelse e.keychar="0" then
q.clear // list.clear
else
q.dequeue // list.removeat(0)
end if
end if
else
q.clear // list.clear
end if
end select
end sub
طبق مثالی که آوردین شرط ها بر این اساس بوده که برای کلید اول فقط ارقام 0-9 و کلید دوم فقط alphanumeric،
غیر از این هست ویرایش کنین.