GERANDO UM TXT

USUARIO.EXCLUIDOS 20/01/2005 14:11:29
#61999
Olá meu povo ,
Gostaria que meu programa em VB fizesse o Seguinte:

quando eu apertasse a tecla 1 ele registraria um voto em um arquivo TXT , se eu apertasse 10 vezes a tecla 1 , no txt teria que estar o valor 10 como faço?
Alguem tem o código fácil para mim ?
USUARIO.EXCLUIDOS 20/01/2005 14:30:52
#62004
Vc pode :

Dim vlTXT as Long 'Valor que esta no txt
Dim vlREAL as long 'Valor que vai estar no txt

PrimeiroLe() 'Aqui vc abre o txt e guarda o vl no vlTXT

vlREAL = ValorTeclaDigitada + vlTXT 'Se digitarmos 1 passa um 9 passa dae soma com o que esta anteriormente

SobrescreveTXT(vlREAL)

Pronto simples


GABRIEL.LOGAN 20/01/2005 14:40:01
#62005
Resposta escolhida
Private Sub FORM_KeyPress(KeyAscii As Integer)
dim numero as string

If KeyAscii = 49 Then
numero = "1"
open "c:    este.txt" for output as #1
Print #1, numero
close #1
Else
End If

If KeyAscii = 57 Then
numero = "9"
open "c:    este.txt" for output as #1
Print #1, numero
close #1
Else
End If

end sub

COM O Nº 10 NÃO DA PORQUE NÃO EXISTE O Nº 10 NO TECLADO, você deve substituir a tecla " 10 que não existe por outra".

KEYASCII DE 1 A 9: (colocar no Private Sub FORM_KeyPress(KeyAscii As Integer))

0:

If KeyAscii = 48 Then

Else

End If

1:

If KeyAscii = 49 Then

Else

End If

2:

If KeyAscii = 50 Then

Else

End If


3:

If KeyAscii = 51 Then

Else

End If


4:

If KeyAscii = 52 Then

Else

End If


5:

If KeyAscii = 53 Then

Else

End If

6:


If KeyAscii = 54 Then

Else

End If

7:


If KeyAscii = 55 Then

Else

End If


8:

If KeyAscii = 56 Then

Else

End If

9:

If KeyAscii = 57 Then

Else

End If


LEMBRE-SE:
Tópico encerrado , respostas não são mais permitidas