Aller au contenu principal

Recherche

Recherche

Can't Set Fontsize In Vb-Script. Bug?

Commentaires

15 commentaires

  • Avatar
    Ian Cummings
    Modérateur

    Any reason why you don't use the auto size option in the text object properties of your label design?

     

    Can you attach an example document that demonstrates the issue to examine, or failing that the full script.

    0
  • Avatar
    Legacy Poster

    OK,  see Attachment.  For test please copy files to C:\BtTest.

    Both Object/Controls have a synchron Zoom for FontSize in VB-Script.

    I can use HTML Ort XAML, but not Text Object for change FontSize.

     

    My Question is: is it a bug?

    Thanks.


     

    0
  • Avatar
    Legacy Poster

    ' Solution for HTML-Label with VB-Script:

     

    ''''' In Function and Sub '''''

    Function HtmlVorPrice(Price)
    Dim s, length, digits_before_point, digits_after_point, size

    s = Price & ""
    length = Len(s)

    ' min 4 chararcter, by < "0,00" no output
    If length < 4 Then
    HtmlVorPrice ="<html><body></body></html>"
    Exit Function
    End If

     

    digits_before_point = Left(s, length - 3 )
    digits_after_point = Right(s, 2)

     

    Select Case Len(s)
    Case 4: size = 13
    Case 5: size = 12
    Case 6: size = 12
    Case 7: size = 10
    Case 8: size = 10
    Case 9: size = 9
    Case 10: size = 8
    Case Else: size = 7
    End Select

    s = "<html>" & vbCrLf & _
    "<head>" & vbCrLf & _
    " <style type='text/css'>" & vbCrLf & _
    " body {font-family: 'Arial Narrow'; font-size: '" & size & "pt'; font-weight: bold;}" & vbCrLf & _
    " </style>" & vbCrLf & _
    "</head>" & vbCrLf & _
    "<body>" & vbCrLf & _
    " <center>" & vbCrLf & _
    digits_before_point & "<sup style='font-size:70%'> <u>" & digits_after_point & "</u></sup>" & vbCrLf & _
    " </center>" & vbCrLf & _
    "</body>" & vbCrLf & _
    "</html>"

    HtmlVorPrice = s
    End Function

     

    ''''' In OnNewRecord '''''

    ReferenceField "txt_price"
    Value = HtmlVorPrice(Field("txt_price"))

     

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Output for Price = "5,00":
     

        500
     

    ' Digits before and after decimal point zoomed synchronously, ' If Len(Price) > 4:
        1000 00

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

     

    Bad output with auto size and two labels is:

    100000

     

    

    

    

    0
  • Avatar
    Ian Cummings
    Modérateur

    I'm confused now.  Are you having problem using standard BarTender text, or using HTML container text??  Your posts suggest that the HTML route is your workaround, and yet you've not sent me the BarTender document (best) or VB script of the implementation which that you're having problems.

    0
  • Avatar
    Legacy Poster

    Sorry, i had a Problem with upload.

    For a Price-Label i've created two BarTender-Objects  (Text type) and FontSize = 12 and 10.

    Example:   500

    For Price with more as 3 digits have i written in VB-Script

     

    Format.Objects("price_before_dec_point").FontSize= 7  

    Format.Objects("price_after_dec_point").FontSize  = 5

     

    That worked, but after start was FontSize = 1, always !

    This was my first question: "Is it a Bug?"

    Unfortunately, my question was not answered.

     

    If i use the auto size function, is the Result for 5,00 and 1000,00 :

    500  and 100000 
    Smaller is only first field (5->1000, not 00-> 00).

    This is not a synchron Zoom for both fields!

     

    Correct result is 500  and 1000 00
    In my previous answer is a solution for this Problem. I use VB-Script in a HTML-object.

    But this is a complex solution …

     

    My question: works VB-Script FontSize with a Text-Object, or is it a bug? (always changed to 1 Point)

     

    Sorry for my poor knowledge of english.

    Thanks.

    0
  • Avatar
    Ian Cummings
    Modérateur

    I suggest you attach your example BarTender document, so I can see what you're doing, as your explanations are not crystal clear to me.  If you're connecting to a data file of some kind please attach that too.  Note you might need to use a simple delimited text file for the purpose of demonstration.

     

    I'm not aware of a bug in this area, but at the moment I'm not sure on what you're doing exactly so cannot go about trying to reproduce the error. 

    0
  • Avatar
    Legacy Poster

    Demo for FontSize - Bug:

     

    [attachment=797:FontSizeNotOK.btw]

    [attachment=798:FontSizeNotOK.txt]

     

    0
  • Avatar
    Ian Cummings
    Modérateur

    Your code in the document level VB script was bad, so I rewrote it for you in a nested If...Then statement.  Note that you can set a second argument (for a default value) in the Field() function call in order to avoid design time errors.

     

    ReferenceField("FontSizeNotOK.FontSize") 
    
    If IsNumeric(Field("FontSizeNotOK.FontSize",12)) Then
    
        If Field("FontSizeNotOK.FontSize",101) > 100 Then
                Format.Objects("Text 1").FontSize = 100
        Else
                Format.Objects("Text 1").FontSize = Field("FontSizeNotOK.FontSize",12)
        End If
    
    Else
        Format.Objects("Text 1").FontSize = 100
    End If 
    
    0
  • Avatar
    Legacy Poster

    Good, the Function Field() has a optional 2. Parameter for default Value.

    But after run

    Format.Objects("Text 1").FontSize = 100 or

    Format.Objects("Text 1").FontSize = Field("FontSizeNotOK.FontSize",12)

    is FontSize equal 1. Please send a bug report to the BarTender developer team.

     

    Best regards and end of discussion.

    0
  • Avatar
    Ian Cummings
    Modérateur

    I'm not sure what you're getting at there.  As per the attached and the preview, all works fine for me.

     

    *Note you'll need to adjust back the location of the data file.

    0
  • Avatar
    Legacy Poster

    Sorry, don't work ...

    My Version: Enterprise Automation 10.1 SR2 Build 2945 (Windows 7 x86 SP1) Location: Germany.

    After new BarTender-download and new installation the same effekt.

    Please see the PNG-File.

    [attachment=859:FonSizeNotOK!.PNG]

    0
  • Avatar
    Ian Cummings
    Modérateur

    Attach the files you're working with so we can see what's wrong.

    0
  • Avatar
    Legacy Poster

    How have they recommended I have indeed used your files from 13.02.2014.

    To download I used this link:

    http://www.bartenderbarcodesoftware.com/ftp/BarTender/10.1/BT101_SR2_2945_Suite.exe

    Thanks for your help, but this must Developer check. I'll wait for the next update.

    0
  • Avatar
    Ian Cummings
    Modérateur

    I don't know what you're doing wrong, but it works absolutely fine on my PC.  This is not a BarTender version issue.

    0
  • Avatar
    Legacy Poster

    I've got the exact same issue.

    I'm using activeX to control bartender within Internet Explorer.

    Everything works fine except setting FontSize. FontSize is always 1 after modifying its value.

    I've tried to use another object fontsize value but it is the same.

     

    I'm using BT 10.1 SR3

    0

Vous devez vous connecter pour laisser un commentaire.