El detalle esta en que en las variables "valor" no haces la conversion como debe de ser; vos lo haces asi:
Código:
valor2 = Format(txtpeajesotros.Text, "#,#0.00")
' lo que esta en negrilla es el error; lo correcto es asi:
valor2 = Format(txtpeajesotros.Text, "##0.00")
' ves la diferencia
Voy a dejar el codigo completo de como yo lo hice; espero te ayude en algo:
Código:
Private Sub Command1_Click()
Dim valor1, valor2, sumatoria As String
' convertimos los valores de las cajas de texto a formato numerico
valor1 = Format(Text1.Text, "##0.00")
valor2 = Format(Text2.Text, "##0.00")
' tomamos los valores convertidos y los sumamos
' el resultado lo almacenamos en la variable sumatoria
sumatoria = Val(valor1) + Val(valor2)
' en el Text3 ponemos la sumatoria en formato de moneda
Text3.Text = Format(sumatoria, "$#,##0.00")
'Text3.Text = Format(sumatoria, "#,##0.00")
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text1.Text = Format(Text1.Text, "$#,##0.00")
SendKeys "{tab}"
End If
End Sub
Private Sub Text1_LostFocus()
Text1.Text = Format(Text1.Text, "$#,##0.00")
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.Text = Format(Text2.Text, "$#,##0.00")
SendKeys "{tab}"
End If
End Sub
Private Sub Text2_LostFocus()
Text2.Text = Format(Text2.Text, "$#,##0.00")
End Sub
Si queres probarlo crea un proyecto en Visual Basic; y pega tres TextBox y un Command; colocalos como te plazca, pero no le cambies el nombre a ninguno de los controles.
Suerte