User Interface - Mobile Phone

manic2511
04-24-2005, 12:26 PM
I am trying to make a simple user-interface for a mobile phone. I have all the designs worked out and have made all the forms, pictures, labels etc. however, as i am so new to the language I am having troubles trying to code the text messaging screen. All I think I need is a text box that when you press 2 on the keypad for example, it comes up 'a' in the text box, press it again and it comes up 'b' etc. just like an ordinary mobile phone. But does anyone know how i should code this?

also, it would be nice if the text box had a little timer so if no button was pressed in 3 seconds or so, the text cursor would move on to the next character.

Many thanks

GavinO
04-24-2005, 02:52 PM
You probably want to store the string internally as well as display it in the box. That way, you can differentiate between what has been typed and the current character being constructed (ie, set the textbox text to the entered string + the current state of the character to be edited, appending that character to the stored string only after it is finalized). As for a timer, the neat way would be to use SetTimer and KllTimer to have the 'next character' function called after a certain amount of time (resetting the timer whenever one of your buttons is pressed).

manic2511
04-24-2005, 04:43 PM
You probably want to store the string internally as well as display it in the box. That way, you can differentiate between what has been typed and the current character being constructed (ie, set the textbox text to the entered string + the current state of the character to be edited, appending that character to the stored string only after it is finalized). As for a timer, the neat way would be to use SetTimer and KllTimer to have the 'next character' function called after a certain amount of time (resetting the timer whenever one of your buttons is pressed).

I know this is cheeky, but would it be possible to give me a sample of the code of what you mean for the text part?

Your idea on SetTimer and KillTimer seems spot on to me!!!

Thanks

GavinO
04-24-2005, 07:34 PM
When you press a button, you're going to be updating a variable storing the current character. This update is made based on the number of times that key has been pressed sequentially. In any case, you have a character in a string. We'll call this string currChar. You also have all of the text that has been typed thus far. We'll call this allText. The logic for a given button press looks something like this:

- If I was the last button pressed, then I would increment the pressed counter (something like counter=(counter+1) mod 4)
- If some other button was pressed last, then I append currChar to allText, and reset the pressed counter
- I assign to currChar what character I represent for the given number of presses
- I assign to the text of the textbox the entered string and the current character (TextBox.Text=allText & currChar)

The operations for "I wasn't pressed last" will also be applicable for the next character button and for the timer (I sense a subroutine ...)

manic2511
04-25-2005, 06:58 AM
I'm lost lol

At the moment all of my keys are members of an array from 'label1'. So to get an 'a' to appear, I have the following code:

If Label1(Index) = Label1(2) And TextMessage.Visible = True Then
TextMessage.Text = "a"
counter = counter + 1
End If

I have declared counter, currentChar, and allText as public integers but as my knowledge of VB programming is not good, I don't know exactly how to express what I am trying to do. Obviously if label1(2) is pressed 3 times in quick succession then I need to write a 'c' to TextMessage as opposed to an 'a'

Thanks for all your help

GavinO
04-25-2005, 11:15 AM
Why are you comparing the default properties as the if condition? Just compare Index (and a Select Case would be better). You'll need to have some way of determining what the list of characters is for each key. for example, the 2 key is [a,b,c,2]. You could put them in an array, or just a string that you grab a character from with Mid$(), or whatever. Counter is going to be how you index into that array or string.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum