VB Scripting Follow
I have a text field I am trying to fill with one of two strings depending on a data import. I have a script written in a new script library that reads:
Public Function RegulationFilter(yr)
If IsNumeric(yr) Then
If yr > 2000 And yr < 2011 Then
reg = "a string"
reg = "b string"
reg = "c string"
RegulationFilter = reg
This builds correctly. If I press Test Script it returns no errors. Then I am trying to figure out how to call this within the textbox (Text 40). I tried putting in Text 40 a script saying
Value = RegulationFilter(Field("data.data.Year"))
but while it does not throw, it just reads out 0 constantly, it is not reading. Then I tried to put it in the document event OnPrintJobStart as
Format.Objects("Text 40").Value = RegulationFilter(Field("data.data.Year"))
so that it had actual data to populate and only ran at the appropriate time, but it complained that it cannot write a readonly property.
Can anyone help me in this? I'm not new to coding in VB as a whole but using it in Bartender is a whole new ballgame for me, so I am not sure really how to go about setting this up. I have been referencing the webinar on VB Scripts that SS put up online but it is only moderately helpful I am finding.
Additionally though this is somewhat off topic, is there a way to use more proper VB formatting? For example in the Function I had to assign RegulationFilter = reg because I can't Return reg, that errs out. Or saying Public Function RegulationFilter(yr As String) As String would be better but it thinks it should go to the next statement. But if this is not doable it's not the end of the world.