PDA

View Full Version : Solved: label.caption take text from file



white_flag
04-01-2010, 07:57 AM
Hello (second time from today)

I would like to add some texts in label(i).caption via an text file whit an marker that will tell from were to were to be fill the label
label1.caption = "text.file-|-this one to be like an marker"
label2.caption = "text.file-|-this one to be like an marker"
.
.
.
label20.caption = "text.file-|-this one to be like an marker"
etc

thx.

Bob Phillips
04-01-2010, 08:52 AM
I would use an XML file



<?xml version="1.0" encoding="utf-8"?>
<app="myApp">

<userform name="myForm">

<control type="label"
name="label1"
caption"text.file-|-this one to be like an marker" />

<control type="label"
name="label2"
caption"text.file-|-this one to be like an marker" />

....

<control type="label"
name="label20"
caption"text.file-|-this one to be like an marker" />
</userform>
</app>


parsing it is a doddle

white_flag
04-01-2010, 09:06 AM
and without xml?
something like this?

InputData = Split(data(i - 1), Chr(13))
For Each t In InputData
If Len(t) > 0 Then _
Me.Controls("label" & i).caption Application.Substitute(t, Chr(10), "")
Next

the reason is that I have all the input data in one file (data for combobox, for the date that to be inserted in rows in columns) and I would like to be the same with the label.caption

white_flag
04-02-2010, 01:04 AM
Set f = fs.GetFile(ActiveWorkbook.Path & "\meniu.dutch")
Open ActiveWorkbook.Path & "\meniu.dutch" For Input As #nFile
Do While Not EOF(nFile)
Input #nFile, sTemp
For i = 10 To 80
If Len(sTemp) > 0 Then
nEqualsSignPos = InStr(sTemp, "=")
nEqualsSignPos = nEqualsSignPos + 1
If InStr(sTemp, "lab" & i) Then
Controls("Label" & i).Caption = Mid(sTemp, nEqualsSignPos)
End If
End If
Next
Loop
Close nFile