Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1.Text = Format(TextBox1.Text, "###,##0.00") 'testformat tal1 = Val(cleanTal(TextBox1.Text))
Range("A2").Value = tal1 'evt. formatter cellen m/separator End Sub Private Function cleanTal(tal) Dim f, nytal nytal = "" For f = 1 To Len(tal) If Mid(tal, f, 1) <> "." Then If Mid(tal, f, 1) = "," Then nytal = nytal + "." Else nytal = nytal + Mid(tal, f, 1) End If End If Next f cleanTal = nytal End Function
hmm. Der er da sket et eller andet.... Nu giver det 782811225
Jeg har lagt din private function cleanTal ind.
Når man klikker på den knap der skal vise beløb afvikles følgende:
Private Sub CommandButton1_Click() Dim tal1 As String If Ob1.Value = True Then TxtFakturering = (([TxtLøn] * 160.33) * [TxtPeriode]) * [TxtAntal] End If If Ob2.Value = True Then TxtFakturering = ((([TxtLøn] * 12) * 10) / 100) * [TxtAntal] End If If Ob3.Value = True And Ob4.Value = True Then TxtFakturering = ((([TxtLøn] * [TxtPeriode]) * 7.4) * [TxtAntal]) End If If Ob3.Value = True And Ob5.Value = True Then TxtFakturering = ((([TxtLøn] * [TxtPeriode]) * 37) * [TxtAntal]) End If If Ob3.Value = True And Ob6.Value = True Then TxtFakturering = ((([TxtLøn] * [TxtPeriode]) * 160.33) * [TxtAntal]) End If TxtLøn = Excel.WorksheetFunction.Substitute(TxtLøn.Value, ",", ".") TxtLøn.Value = TxtLøn.Value TxtFakturering.Text = Format(TxtFakturering.Text, "###,##0.00") 'testformat tal1 = Val(cleanTal(TxtFakturering.Text)) TxtFakturering.Value = tal1 'evt. formatter cellen m/separator Me.TxtFakturering.Visible = True End Sub
Private Sub commandbutton1_click() Dim tal1 ' If Ob1.Value = True Then ' TxtFakturering = (([TxtLøn] * 160.33) * [TxtPeriode]) * [TxtAntal] ' End If ' If Ob2.Value = True Then TxtFakturering = ((([TxtLøn] * 12) * 10) / 100) * 10 ' End If ' If Ob3.Value = True And Ob4.Value = True Then ' TxtFakturering = ((([TxtLøn] * [TxtPeriode]) * 7.4) * [TxtAntal]) ' End If ' If Ob3.Value = True And Ob5.Value = True Then ' TxtFakturering = ((([TxtLøn] * [TxtPeriode]) * 37) * [TxtAntal]) ' End If ' If Ob3.Value = True And Ob6.Value = True Then ' TxtFakturering = ((([TxtLøn] * [TxtPeriode]) * 160.33) * [TxtAntal]) ' End If
End Sub Private Function cleanTal(tal) Dim f, nytal nytal = "" For f = 1 To Len(tal) If Mid(tal, f, 1) <> "." Then If Mid(tal, f, 1) = "," Then nytal = nytal + "." Else nytal = nytal + Mid(tal, f, 1) End If End If Next f cleanTal = nytal End Function
' If Ob1.Value = True Then ' TxtFakturering = (([TxtLøn] * 160.33) * [TxtPeriode]) * [TxtAntal] ' End If ' If Ob2.Value = True Then TxtFakturering = ((([TxtLøn] * 12) * 10) / 100) * 10 ' End If ' If Ob3.Value = True And Ob4.Value = True Then ' TxtFakturering = ((([TxtLøn] * [TxtPeriode]) * 7.4) * [TxtAntal]) ' End If ' If Ob3.Value = True And Ob5.Value = True Then ' TxtFakturering = ((([TxtLøn] * [TxtPeriode]) * 37) * [TxtAntal]) ' End If ' If Ob3.Value = True And Ob6.Value = True Then ' TxtFakturering = ((([TxtLøn] * [TxtPeriode]) * 160.33) * [TxtAntal]) ' End If tal1 = cleanTal(TxtFakturering)
TxtFakturering = Format(tal1, "###,##0.00")
Range("A2").Value = TxtFakturering Range("A2").HorizontalAlignment = xlRight End Sub Private Function cleanTal(tal) Dim f, nytal nytal = "" For f = 1 To Len(tal) If Mid(tal, f, 1) = "." Then nytal = nytal + "," Else nytal = nytal + Mid(tal, f, 1) End If Next f cleanTal = nytal End Function
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.