Substrings Vb.net Follow

0
Avatar
Legacy Poster

Hello,

I'm new here and have a problem with the automation BarTender9.4 in VB.Net. When I have a Database field in my layout and give it a substring name, BarTender print out the database value not the changed substring value. When I have a Screen field it works allright. Can anyone help me with my problem?

4 comments

0
Avatar
Susan Chen
Moderator
Comment actions Permalink

Hi, Patrick:

You want to get the data from database field and then change it ?

1) When Data source(for example sharename: Barcode128) is screen data
// Modify Sharename Barcode128 value to 11111111
btFormat.SubStrings["Barcode128"].Value = "11111111";
-> You can print through SDK with correct value

2) When Data source is database field, you can not get the changed data print out as you want? Do you expect changed data write back into database?

Can you share this specific part of code so that we can check why it is not working on you?



Thanks!
0
Avatar
Legacy Poster
Comment actions Permalink

Hi,

i have a text in the database and want to change a part of the text and print the changed text. I don't want to write the text back in database.

1) Screen data Substrings works fine, I have the code as in your post. My Problem is only by the database field
2) I read the value of the field and put it into a textbox on my form, then I can change the text in the textbox. After that I write the text of the textbox back into the substring value.


[code]
Private Sub frm_Druckeingabe_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' 10 ´Felder neu erzeugen
For i As Integer = 0 To intSubstrings - 1

' Neuen Button erzeugen
lblArray(i) = New Label
txtArray(i) = New TextBox

' Den erzeugten Button verwenden:
With lblArray(i)

' Parent festlegen und Controls-Collection erweitern
.Parent = Me
.Parent.Controls.Add(lblArray(i))

' Verwaltungsinformationen zuweisen
.Name = "Label" & CStr(i)
.TabIndex = i

' Darstellung: Beschriften und positionieren
If frm_Etikettendruck.btFormat.SubStrings(i).Name = "EK" Then
.Text = ""
Else
.Text = frm_Etikettendruck.btFormat.SubStrings(i).Name
End If
.Size = New Size(180, 23)
.Location = New Point(10, 17 + i * 40)
.Visible = True

End With

' Den erzeugten Button verwenden:
With txtArray(i)

' Parent festlegen und Controls-Collection erweitern
.Parent = Me
.Parent.Controls.Add(txtArray(i))

' Verwaltungsinformationen zuweisen
.Name = "Text " & CStr(i)
.TabIndex = i

' Darstellung: Beschriften und positionieren
If frm_Etikettendruck.btFormat.SubStrings(i).Name = "EK" Then
.Text = ""
.Visible = False
Else
.Text = frm_Etikettendruck.btFormat.SubStrings(i).Value
.Visible = True
End If
.Size = New Size(350, 33)
.Location = New Point(200, 10 + i * 40)

End With

Next i
End Sub

Private Sub btn_Fertig_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Fertig.Click
For i As Integer = 0 To intSubstrings - 1
With Me.Controls("Text " & CStr(i))
If Not frm_Etikettendruck.btFormat.SubStrings(i).Name = "EK" Then
frm_Etikettendruck.btFormat.SubStrings(i).Value = .Text
End If
End With
Me.Controls.RemoveByKey("Label" & CStr(i))
Me.Controls.RemoveByKey("Text " & CStr(i))
Next i
boolexit = True
Me.Close()
End Sub[/code]

This is a part of my code. When I make a Debug print after the part where I write the text in the substring, my substring text is like my text in the textbox. I don't know why it print also the database text.


Thanks for your help
0
Avatar
Shotaro Ito
Moderator
Comment actions Permalink

You cannot change database field value from ActiveX, since You can only update Substring Value BEFORE print start, but database field data will be loaded AFTER print job started.

What you can do is...
[list]
[*]Use screen data. If need to get ODBC data, Connect within your VB application and retrieve data.
[*]Use BarTender's user prompt. You can enable User prompt to manually update field value in Datasource's more options > Prompt. You can show user prompt by Application.VisibleWindows = BarTender.BtVisibleWindows.btInteractiveDialogs
[/list]

You can modify database field data in Format, by datasource's more option > VB Script > OnProcessData.
(though that may not what you want - you want to modify database data on your VB form, right?)

[code]'apply number format to field value
If IsNumeric(Value) Then Value=FormatNumber(Value,0) [/code]
hope that helps..
0
Avatar
Legacy Poster
Comment actions Permalink

Hi,

the user prompt is what I had before the substrings and I don't know that it can be shown yet. Its nice that it works. My problem is solved with showing the user promt.

Thanks for your help.

Please sign in to leave a comment.