i am trying to use tabs in reporting service 2008 expression on a particular textbox.
i have tried using three tabs (& vbTab & vbTab & vbTab &) between field name and value for two fields.
=iif(Trim(Fields!Field1.Value) <>"", "FVE1:" & vbTab & vbTab & vbTab & Fields!Field1.Value & VbCrLf,"") & iif(Trim(Fields!Field2.Value) <>"", "RV:" & vbTab & vbTab & vbTab & Fields!Field2.Value,"" )
what i am trying to aceive is some thing like this
FEV1: 3.29
RV: 0.51
But i am unable to achieve this insted it get like below
FEV1: 3.29
RV: 0.51
any help will be much appeiciated.
thanks
If tabs do not work, try right-aligning with non-breaking spaces Chr(160):
(Line-wrapped for legibility)
= Iif(
Trim(Fields!Field1.Value) <> "",
"FVE1:" & Fields!Field1.Value.ToString().PadLeft(5, Chr(160)) & VbNewLine,
""
)
& Iif(
Trim(Fields!Field2.Value) <> "",
"RV:" & Fields!Field1.Value.ToString().PadLeft(5, Chr(160)),
""
)
Related
I am generating an email that shows trades for the day in the body of an email. Currently the only way I can do this is with an If then statement for specific numbers of trades. If we traded 10, I need an if then statement with 10 as the variable criteria, but if I only have 9, then I get an error. I want a dynamic method instead. I can do a For Loop that will list all the trades in debug.print, but in the email, it each trade overwrites the prior trade and I show only one line. I also need an intro like "Hi, today today's trades are: " followed by each trade listed below line by line.
I tried this and it works but only if I have the right number of trades and a variable that matches it. For example, if I had 23 trades, I need an If statement with 23 as a variable value in this case m. I used Arrays as VBA does not let me create a list. Unfortunately, I cannot pull the whole array, I need to pull line by line. If I could pull the array, I could just have a simple loop.
If m = 23 Then
.Body = "Hi Chris," & vbLf & vbLf & "The following trade(s) was completed today:" & vbLf & vbLf & ArrayValues(0) & vbLf & ArrayValues(1) & vbLf & ArrayValues(2) & vbLf & ArrayValues(3) & vbLf & ArrayValues(4) & vbLf & ArrayValues(5) & vbLf & ArrayValues(6) & vbLf & ArrayValues(7) & vbLf & ArrayValues(8) & vbLf & ArrayValues(9) & vbLf & ArrayValues(10) & vbLf & ArrayValues(11) & vbLf & ArrayValues(12) & vbLf & ArrayValues(13) & vbLf & ArrayValues(14) & vbLf & ArrayValues(15) & vbLf & ArrayValues(16) & vbLf & ArrayValues(17) & vbLf & ArrayValues(18) & vbLf & ArrayValues(19) & vbLf & ArrayValues(20) & vbLf & ArrayValues(21) & vbLf & ArrayValues(22) & vbLf & vbLf & "Thanks"
End if
I want to use something like:
For b = 1 To LastRow
If Trades.Range("H" & b) = TDate Then
Debug.Print (Range("B" & b) & " " & Range("C" & b) & " " & Range("D" & b) & " " & Range("F" & b) & " " & Range("G" & b))
End If
Next b
This way it does not matter how may trades I have, one formula would over it all. Each Range has a trade characteristic.
If I do a debug.Print in the immediate window I get a list just like I want, but in the email, each line overwrites the prior trade.
I am a rookie at this and appreciate any help. Thanks
Sounds like you need to build a string which can be assigned to the message body. For such tasks you can use String Functions available in VBA where you can prepare the correct string and then assign to the message body.
If m = 23 Then
.Body = "Hi Chris," & vbLf & vbLf & "The following trade(s) was completed today:" & vbLf & vbLf & ArrayValues(0) & vbLf & ArrayValues(1) & vbLf & ArrayValues(2) & vbLf & ArrayValues(3) & vbLf & ArrayValues(4) & vbLf & ArrayValues(5) & vbLf & ArrayValues(6) & vbLf & ArrayValues(7) & vbLf & ArrayValues(8) & vbLf & ArrayValues(9) & vbLf & ArrayValues(10) & vbLf & ArrayValues(11) & vbLf & ArrayValues(12) & vbLf & ArrayValues(13) & vbLf & ArrayValues(14) & vbLf & ArrayValues(15) & vbLf & ArrayValues(16) & vbLf & ArrayValues(17) & vbLf & ArrayValues(18) & vbLf & ArrayValues(19) & vbLf & ArrayValues(20) & vbLf & ArrayValues(21) & vbLf & ArrayValues(22) & vbLf & vbLf & "Thanks"
End if
Your strategical mistake is that you are trying to set up the Body property for a specific case. Instead, consider concatenating the string with the required piece of data (another string) which makes sense for a particular case. And only when you are done adding all the bits to the result string, you can assign it to the message body.
Be aware, the Body property is a plain text string and doesn't deliver any formatting. Instead, I'd suggest using the HTMLBody property instead. The HTMLBody property should be an HTML syntax string. Setting the HTMLBody property will always update the Body property immediately.
Been trying to figure out if there is a way to deserialize this object below. the problem is the api returns the data in this format. There seems to be an object here called Info that is listof()..
"found=23" & vbCrLf & "info[0].Channel=0" & vbCrLf & "info[0].EndTime=2020-05-11 00:59:59" & vbCrLf & "info[0].EnteredSubtotal=0" & vbCrLf & "info[0].ExitedSubtotal=0" & vbCrLf & "info[0].RuleName=NumberStat" & vbCrLf & "info[0].StartTime=2020-05-11 00:00:00" & vbCrLf & "info[1].Channel=0" & vbCrLf & "info[1].EndTime=2020-05-11 01:59:59" & vbCrLf & "info[1].EnteredSubtotal=0" & vbCrLf & "info[1].ExitedSubtotal=0" & vbCrLf & "info[1].RuleName=NumberStat" & vbCrLf & "info[1].StartTime=2020-05-11 01:00:00" & vbCrLf & "info[2].Channel=0" & vbCrLf & "info[2].EndTime=2020-05-11 02:59:59" & vbCrLf & "info[2].EnteredSubtotal=0" & vbCrLf & "info[2].ExitedSubtotal=0" & vbCrLf & "info[2].RuleName=NumberStat" & vbCrLf & "info[2].StartTime=2020-05-11 02:00:00" & vbCrLf & "info[3].Channel=0" & vbCrLf & "info[3].EndTime=2020-05-11 03:59:59" & vbCrLf & "info[3].EnteredSubtotal=0" & vbCrLf & "info[3].ExitedSubtotal=0" & vbCrLf & "info[3].RuleName=NumberStat" & vbCrLf & "info[3].StartTime=2020-05-11 03:00:00" & vbCrLf & "info
Thanks in advance for any ideas here.
Looks like it is VBscript.
vbCrLf means new line so:
"found=23"
"info[0].Channel=0"
"info[0].EndTime=2020-05-11 00:59:59"
"info[0].EnteredSubtotal=0"
"info[0].ExitedSubtotal=0"
"info[0].RuleName=NumberStat"
"info[0].StartTime=2020-05-11 00:00:00"
"info[1].Channel=0"
"info[1].EndTime=2020-05-11 01:59:59"
"info[1].EnteredSubtotal=0"
"info[1].ExitedSubtotal=0"
"info[1].RuleName=NumberStat"
"info[1].StartTime=2020-05-11 01:00:00"
"info[2].Channel=0"
"info[2].EndTime=2020-05-11 02:59:59"
"info[2].EnteredSubtotal=0"
"info[2].ExitedSubtotal=0"
"info[2].RuleName=NumberStat"
"info[2].StartTime=2020-05-11 02:00:00"
"info[3].Channel=0"
"info[3].EndTime=2020-05-11 03:59:59"
"info[3].EnteredSubtotal=0"
"info[3].ExitedSubtotal=0"
"info[3].RuleName=NumberStat"
"info[3].StartTime=2020-05-11 03:00:00"
I think this might be useful:
How to run VBScript in .net core or .net standard project?
I have the below Excel 2010 VBA that is in two parts. The first portion checks if a CheckBox on a sheet is checked, if it then it adds the value of a specified cell to the sample_descriptor.txt in the portion below that. Currently I am getting a
subscript out of range error
and am not sure if this is the best way to accomplish this task. Thank you :). The value for comment1 is F9, comment2 is F10, comment3 is F11, and comment4 is F12
VBA
' ADD COMMENT IF ANY '
If CheckBox17.Value = True Then
Worksheets("Sheet1").Range("F9") = ActiveSheet.Range("F9").Value
Else
Worksheets("Sheet1").Range("F9") = "No Issues"
End If
If CheckBox17.Value = True Then
Worksheets("Sheet1").Range("F10") = ActiveSheet.Range("10").Value
Else
Worksheets("Sheet1").Range("F10") = "No Issues"
End If
If CheckBox17.Value = True Then
Worksheets("Sheet1").Range("F11") = ActiveSheet.Range("F11").Value
Else
Worksheets("Sheet1").Range("F11") = "No Issues"
End If
If CheckBox17.Value = True Then
Worksheets("Sheet1").Range("F12") = ActiveSheet.Range("F12").Value
Else
Worksheets("Sheet1").Range("F12") = "No Issues"
End If
Unload Me
'WRITE TO SAMPLE DESCRIPTOR.txt '
Open MyDirectory & "sample_descriptor.txt" For Output As #1
Print #1, "Experiment Sample" & vbTab & "Control Sample" & vbTab & "Display Name" & vbTab & "Gender" & vbTab & "Control Gender" & vbTab & "Spikein" & vbTab & "Location" & vbTab & "Barcode" & vbTab & "Medical Record" & vbTab & "Date of Birth" & vbTab & "Order Date"
Print #1, "2571683" & MyBarCode & "_532Block1.txt" & vbTab & "2571683" & MyBarCode & "_635Block1.txt" & vbTab & ActiveSheet.Range("B8").Value & " " & ActiveSheet.Range("B9").Value & vbTab & ActiveSheet.Range("B10").Value & vbTab & ActiveSheet.Range("B5").Value & vbTab & Split(ActiveSheet.Range("B11").Value, " [")(0) & vbTab & ActiveSheet.Range("B12").Value & vbTab & "2571683" & MyBarCode & vbTab & ActiveSheet.Range("C200").Value & vbTab & ActiveSheet.Range("D200").Value & vbTab & ActiveSheet.Range("E200").Value & IIf(Sheet.CheckBox17, vbTab & ActiveSheet.Range("F9").Value, "")
Print #1, "2571683" & MyBarCode & "_532Block2.txt" & vbTab & "2571683" & MyBarCode & "_635Block2.txt" & vbTab & ActiveSheet.Range("C8").Value & " " & ActiveSheet.Range("C9").Value & vbTab & ActiveSheet.Range("C10").Value & vbTab & ActiveSheet.Range("C5").Value & vbTab & Split(ActiveSheet.Range("C11").Value, " [")(0) & vbTab & ActiveSheet.Range("C12").Value & vbTab & "2571683" & MyBarCode & vbTab & ActiveSheet.Range("C201").Value & vbTab & ActiveSheet.Range("D201").Value & vbTab & ActiveSheet.Range("E201").Value & IIf(Sheet.CheckBox17, vbTab & ActiveSheet.Range("F10").Value, "")
Print #1, "2571683" & MyBarCode & "_532Block3.txt" & vbTab & "2571683" & MyBarCode & "_635Block3.txt" & vbTab & ActiveSheet.Range("D8").Value & " " & ActiveSheet.Range("D9").Value & vbTab & ActiveSheet.Range("D10").Value & vbTab & ActiveSheet.Range("D5").Value & vbTab & Split(ActiveSheet.Range("D11").Value, " [")(0) & vbTab & ActiveSheet.Range("D12").Value & vbTab & "2571683" & MyBarCode & vbTab & ActiveSheet.Range("C202").Value & vbTab & ActiveSheet.Range("D202").Value & vbTab & ActiveSheet.Range("E202").Value & IIf(Sheet1.CheckBox17, vbTab & ActiveSheet.Range("F11").Value, "")
Print #1, "2571683" & MyBarCode & "_532Block4.txt" & vbTab & "2571683" & MyBarCode & "_635Block4.txt" & vbTab & ActiveSheet.Range("E8").Value & " " & ActiveSheet.Range("E9").Value & vbTab & ActiveSheet.Range("E10").Value & vbTab & ActiveSheet.Range("E5").Value & vbTab & Split(ActiveSheet.Range("E11").Value, " [")(0) & vbTab & ActiveSheet.Range("E12").Value & vbTab & "2571683" & MyBarCode & vbTab & ActiveSheet.Range("C203").Value & vbTab & ActiveSheet.Range("D203").Value & vbTab & ActiveSheet.Range("E203").Value & IIf(Sheet1.CheckBox17, vbTab & ActiveSheet.Range("F12").Value, "")
Close #1
file format
x
x 1 2 3 4
x 11 22 33 44
x --- --- --- ---
x Male Male Female Male
x --- --- --- ---
x 1 2 3 4 Please check the box to add comment
x 1111 2222 3333 4444 (checkbox17)
x xxx,xxx xxx,xxx xxx,xxx xxx,xxx comment1
x Male Male Female Male comment2
x xx xx xx xx comment3
x x x x x comment4
You must change:
ActiveSheet.Range("10").Value
into:
ActiveSheet.Range("F10").Value
But you can shorten down your code to:
If CheckBox17 Then
Worksheets("Sheet1").Range("F9:F12").value = ActiveSheet.Range("F9:F12").value
Else
Worksheets("Sheet1").Range("F9:F12") = "No Issues"
End If
I have data in dataset which I am loopping to build up data for the email the data is as follows but I am using the following to produce the email using tabs but it doesnt see very iffiencet i can only use plain text is their a better way to get it to format nicer like using the datatable sizes or something
Dim dataForEmail As String = ""
Dim msg As String = ""
msg = "The Following Deliverys where processed for the Following Ordernumbers at " & DateTime.Now.ToString() & Chr(13)
dataForEmail = "Order Number" & vbTab & "BarCode" & vbTab & vbTab & vbTab & "Description" & vbTab & vbTab & vbTab & vbTab & vbTab & "Brand" & vbTab & vbTab & vbTab & "Size" & vbTab & "Colour" & vbTab & "Price" & vbTab & "RRP" & vbTab & vbTab & vbTab & "Qty" & Chr(13)
Dim totalcost As Decimal
If Not IsNothing(results) AndAlso Not IsNothing(results.Rows) _
AndAlso results.Rows.Count > 0 Then
For Each thisRow As DataRow In results.Rows
CreateDeliveryIncFileForGemini(thisRow)
totalcost = totalcost + thisRow.Item("RRPPrice")
dataForEmail = dataForEmail & BuildReportFoEmail(thisRow)
connection.ExecuteNonQuerySql(scriptBuilder.SetDeliveryStatus(2, 1, thisRow.Item("r3DeliveryId")))
Next
connection.ExecuteNonQuerySql(scriptBuilder.SetDeliveryStatus(1, 0))
dataForEmail = dataForEmail & vbCrLf & "Total Price " & totalcost.ToString()
SendEmailViaWebService(dataForEmail, cfb.EmailForDeliverys, cfb.FullNameForEmailSubject, msg)
End If
CloseConnection()
I have a formula which hardcoded should look like this:
=SUMMEWENNS(Rawdata!K2:K3446;Rawdata!I2:I3446;"bezahlt";Rawdata!A2:A3446;">="&DATWERT("18.03.2013 00:00");Rawdata!A2:A3446;"<="&DATWERT("24.03.2013 23:59"))
I want to add the formula via VBA into different cells and have come up with this string, but there is a syntax problem and I cannot find the error. It most likely has to do with the escaping of the characters espacially with the "DATWERT".
qq = Chr(34)
Cells(5, fieldextsales).FormulaLocal = "=SUMMEWENNS(RawData!K2:K" & _
maxnumrows & ";Rawdata!I2:I" & maxnumrows & ";" & qq & _
"bezahlt" & qq & ";Rawdata!A2:A" & maxnumrows & ";" & _
qq & ">= " & DATWERT(weekstart & " 00:00") * 1 & qq & _
";RawData!A2:A" & maxnumrows & ";" & qq & "<= " & _
DATWERT(weekend & " 23:59") * 1 & qq & ")"
Could anybody help me out? Hope I get the hang of it then.
Thx
Here we go:
"=SUMMEWENNS(RawData!K2:K" & _
maxnumrows & ";Rawdata!I2:I" & maxnumrows & ";" & _
"""bezahlt""" & ";Rawdata!A2:A" & maxnumrows & ";" & _
""">=""&DATWERT(""" & weekstart & " 00:00"")" & _
";RawData!A2:A" & maxnumrows & ";" & _
"""<=""&DATWERT(""" & weekend & " 23:59""))"
From the VBA side you use plain English function names, not local names => DATWERT shoud be DateValue, unless you want to embed it into your formula.