AW: TextBox mit varible füllen
14.02.2020 12:47:31
RalfBe
Guten Tag,
das Codefragment ist bewusst so kurz, da der Rest einwandfrei funktioniert, u.A. With, Dim usw. Die Dim-Zeile war nachträglich hinzugefügt, um zu zeugen, dass alles außer rred als Integer definiert ist. Es geht nur um die Zeilen zwischen "red=..." und "TextBox_R.Text..." dazwischen muss die Übergabe erfolgen. Die TextBox ist selbstverständlich in einer UserForm plaziert.
Dim lastP, red, blue, green, komma1, komma2 As Integer
Dim rred As String
With ThisWorkbook.Worksheets("xy")
lastP = .Cells(Rows.Count, 2).End(xlUp).Row + 1
komma1 = InStr(1, .Cells(lastP, 6).Value, ",")
komma2 = InStr(komma1 + 1, .Cells(lastP, 6).Value, ",")
red = Mid(.Cells(lastP, 6).Value, 5, komma1 - 5)
green = Mid(.Cells(lastP, 6).Value, komma1 + 1, (komma2 - 1) - komma1)
blue = Mid(.Cells(lastP, 6).Value, komma2 + 1, Len(.Cells(lastP, 6).Value) - 1 - komma2)
rred = CInt(red)
Debug.Print red
Me.TextBox_PNr = "x"
Me.TextBox_PBsch = "y"
Me.TextBox_B.Text = CInt(blue)
Me.TextBox_G.Text = CInt(green)
Me.TextBox_R.Text = CStr(rred)
Spin_R.Value = Me.TextBox_R
Spin_R.Max = 255
Spin_R.Min = 0
Spin_R.SmallChange = 2
Spin_R.Delay = 0
Spin_B.Value = Me.TextBox_B
Spin_B.Max = 255
Spin_B.Min = 0
Spin_B.SmallChange = 2
Spin_B.Delay = 0
Spin_G.Value = Me.TextBox_G
Spin_G.Max = 255
Spin_G.Min = 0
Spin_G.SmallChange = 2
Spin_G.Delay = 0
'Sources
frmxy.ComboBox_PNr.RowSource = "B4:B" & lastP
End With
End Sub