Visual Basic.NET - cambiar de numeros a letras

 
Vista:

cambiar de numeros a letras

Publicado por kota (2 intervenciones) el 20/04/2006 09:03:53
hola

me gustaria que alguien me hiciera el favor de decirme como puedo resolver una aplicacion que permita mostar un numero ingresado por el usuario en letras

ejemplo
10 se debe mostrar diez

en el textbox1 introducir el numero 10 y aplastar el button1 y que aparesca en el textbox2 el numero 10 pero en letra
ahhhh solamente los numeros del 1 al 10
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:cambiar de numeros a letras

Publicado por luis (9 intervenciones) el 20/04/2006 11:54:27
Dim numero(10) As Integer
Dim palabra(10) As String
Dim i As Integer
Dim palabras As String

#Region " Código generado por el Diseñador de Windows Forms "

Public Sub New()
MyBase.New()

'El Diseñador de Windows Forms requiere esta llamada.
InitializeComponent()

'Agregar cualquier inicialización después de la llamada a InitializeComponent()

End Sub

'Form reemplaza a Dispose para limpiar la lista de componentes.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Requerido por el Diseñador de Windows Forms
Private components As System.ComponentModel.IContainer

'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento
'Puede modificarse utilizando el Diseñador de Windows Forms.
'No lo modifique con el editor de código.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(32, 48)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(104, 20)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox1"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(176, 48)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(104, 24)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Label1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(176, 152)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(88, 32)
Me.Button1.TabIndex = 2
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

palabras = "uno,dos,tres,cuatro,cinco,seis,siete,ocho,nueve,diez"
palabra = palabras.Split(",")
For i = 0 To 9
numero(i) = i + 1
Next

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
i = TextBox1.Text
Label1.Text = palabra(i - 1)
End Sub
End Class
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:cambiar de numeros a letras

Publicado por luis (9 intervenciones) el 20/04/2006 13:28:12
así está un poco mejor

Public Class Form1
Inherits System.Windows.Forms.Form

Dim numero(10) As Integer
Dim palabra(10) As String
Dim i As Integer
Dim palabras As String
Dim num As Integer
Dim encontrado As Boolean = False


#Region " Código generado por el Diseñador de Windows Forms "

Public Sub New()
MyBase.New()

'El Diseñador de Windows Forms requiere esta llamada.
InitializeComponent()

'Agregar cualquier inicialización después de la llamada a InitializeComponent()

End Sub

'Form reemplaza a Dispose para limpiar la lista de componentes.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Requerido por el Diseñador de Windows Forms
Private components As System.ComponentModel.IContainer

'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento
'Puede modificarse utilizando el Diseñador de Windows Forms.
'No lo modifique con el editor de código.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(32, 48)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(104, 20)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox1"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(176, 48)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(104, 24)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Label1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(176, 152)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(88, 32)
Me.Button1.TabIndex = 2
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

palabras = "uno,dos,tres,cuatro,cinco,seis,siete,ocho,nueve,diez"
palabra = palabras.Split(",")
For i = 0 To 9
numero(i) = i + 1
Next

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
i = 0
encontrado = False
'Label1.Text = palabra(TextBox1.Text - 1)
While i < 10 And encontrado = False
num = String.Compare(palabra(i), TextBox1.Text)
If num = 0 Then
Label1.Text = numero(i)
encontrado = True

Else
If TextBox1.Text = numero(i).ToString Then
Label1.Text = palabra(i)
encontrado = True
End If
End If
i = i + 1
End While
End Sub
End Class
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar