Here is some math code that adds A to B:
Sub math()
A = 23
B = 2
ABSumTotal = A + B
strMsg = "The answer is " & "$" & ABSumTotal & "."
MsgBox strMsg
End Sub
But how can I calculate a square root of ABSumTotal?
Is it possible in PowerPoint VBA?
Use: Sqr()
strMsg = "The answer is " & "$" & Sqr(ABSumTotal) & "."
Have you tried the function Sqr?
See:
http://msdn.microsoft.com/en-us/library/h2h9y284%28VS.85%29.aspx
You can use use ^ to compute X^(1/2)
Edit: added parenthesis
Related
I'm computing a new variable in a large df in r. I wrote some code that fills my empty cells:
data2$departure_time[which(data2$No=="3" & data2$Key=="300111")]<-data2$departure_time[which(data2$No== "2" & data2$Key=="300111")] + data2$travel_time[which(data2$No=="2" & data2$Key=="300111")] + data2$waiting_time[which(data2$o=="2" & data2$Key=="300111")]
this works so far. yet i need to adapt No-statement in the code every time. What needs to be done is just add 1 to each No statement.
So the result would be:
data2$departure_time[which(data2$No=="4" & data2$Key=="300111")]<-data2$departure_time[which(data2$No== "3" & data2$Key=="300111")] + data2$travel_time[which(data2$No=="3" & data2$Key=="300111")] + data2$waiting_time[which(data2$o=="3" & data2$Key=="300111")]
And so on..
I tried to implement a for-loop into my code as I thougt I would be the easiest solution. So I tried the following:
for(in in 3:40){data2$departure_time[which(data2$No=i & data2$Key=="300111")]<-for(j in 2:40){data2$departure_time[which(data2$No= j & data2$Key=="300111")] + data2$travel_time[which(data2$No= j & data2$Key=="300111")] + data2$waiting_time[which(data2$No=j & data2$Key=="300111")]}}
Unfortunately this didn't work out. I never wrote a loop in R and don't know how to solve this otherwise.
Thank you in advance!
Okay, so I got to generate this string to be SHA1 hashed. I have it like this
string = "ACCEPTURL=SOMErandomSITE/betaling1.aspxblablaRANDOMNMBRAMOUNT=" & visabedrag3 & "blablaRANDOMNMBRBGCOLOR=#FFFFFFblablaRANDOMNMBRBRAND=VISAblablaRANDOMNMBRBUTTONBGCOLOR=#9BCC83blablaRANDOMNMBRBUTTONTXTCOLOR=#000000blablaRANDOMNMBRCANCELURL=SOMErandomSITE/betaling4.aspxblablaRANDOMNMBRCATALOGURL=SOMErandomSITEblablaRANDOMNMBRCN=" & Session('fac_cntnaam_tsv') Session('fac_cntnaam')Session('bdr_fac_cntnaam_tsv') Session('bdr_fac_cntnaam') & "blablaRANDOMNMBRCOM=Ordernummer " & Shop.Order.Ordernummer & "blablaRANDOMNMBRCURRENCY=EURblablaRANDOMNMBRDECLINEURL=SOMErandomSITE/betaling2.aspxblablaRANDOMNMBREMAIL=" & Session('bdr_fac_cntemail')Session('fac_cntemail') & "blablaRANDOMNMBREXCEPTIONURL=SOMErandomSITE/betaling3.aspxblablaRANDOMNMBRFONTTYPE=arialblablaRANDOMNMBRHOMEURL=SOMErandomSITELANGUAGE=nl_NLblablaRANDOMNMBRLOGO=logo.gifblablaRANDOMNMBRORDERID=" & Shop.Order.Ordernummer & "blablaRANDOMNMBROWNERADDRESS=" & Session('facadres') Session('facadres_nr')Session('bdr_facadres') Session('bdr_facadres_nr') & "blablaRANDOMNMBROWNERZIP=" & Session('facpostcode')Session('facpostcode_letters')Session('bdr_facpostcode')Session('bdr_facpostcode_letters') & "blablaRANDOMNMBRPM=creditcardblablaRANDOMNMBRPSPID=reservecornerblablaRANDOMNMBRTBLBGCOLOR=#ecececblablaRANDOMNMBRTBLTXTCOLOR=#4d4d4dblablaRANDOMNMBRTITLE=Betalen met VisablablaRANDOMNMBRTP=SOMErandomSITE/logo.gifblablaRANDOMNMBRTXTCOLOR=#000000blablaRANDOMNMBR"
But the error I get now is BC30201: Expression expected. What am I doing wrong? It's been years since I've done ASP.net
You have missed Variable Name
string sss="value";// In this line(Code) means variable declaration
where,
string means variable data type
sss means variable name
"value" means variable value
try this
string data = "ACCEPTURL=SOMErandomSITE/betaling1.aspxblablaRANDOMNMBRAMOUNT=" & visabedrag3 & "blablaRANDOMNMBRBGCOLOR=#FFFFFFblablaRANDOMNMBRBRAND=VISAblablaRANDOMNMBRBUTTONBGCOLOR=#9BCC83blablaRANDOMNMBRBUTTONTXTCOLOR=#000000blablaRANDOMNMBRCANCELURL=SOMErandomSITE/betaling4.aspxblablaRANDOMNMBRCATALOGURL=SOMErandomSITEblablaRANDOMNMBRCN=" & Session('fac_cntnaam_tsv') Session('fac_cntnaam')Session('bdr_fac_cntnaam_tsv') Session('bdr_fac_cntnaam') & "blablaRANDOMNMBRCOM=Ordernummer " & Shop.Order.Ordernummer & "blablaRANDOMNMBRCURRENCY=EURblablaRANDOMNMBRDECLINEURL=SOMErandomSITE/betaling2.aspxblablaRANDOMNMBREMAIL=" & Session('bdr_fac_cntemail')Session('fac_cntemail') & "blablaRANDOMNMBREXCEPTIONURL=SOMErandomSITE/betaling3.aspxblablaRANDOMNMBRFONTTYPE=arialblablaRANDOMNMBRHOMEURL=SOMErandomSITELANGUAGE=nl_NLblablaRANDOMNMBRLOGO=logo.gifblablaRANDOMNMBRORDERID=" & Shop.Order.Ordernummer & "blablaRANDOMNMBROWNERADDRESS=" & Session('facadres') Session('facadres_nr')Session('bdr_facadres') Session('bdr_facadres_nr') & "blablaRANDOMNMBROWNERZIP=" & Session('facpostcode')Session('facpostcode_letters')Session('bdr_facpostcode')Session('bdr_facpostcode_letters') & "blablaRANDOMNMBRPM=creditcardblablaRANDOMNMBRPSPID=reservecornerblablaRANDOMNMBRTBLBGCOLOR=#ecececblablaRANDOMNMBRTBLTXTCOLOR=#4d4d4dblablaRANDOMNMBRTITLE=Betalen met VisablablaRANDOMNMBRTP=SOMErandomSITE/logo.gifblablaRANDOMNMBRTXTCOLOR=#000000blablaRANDOMNMBR"
and also you need to concatenation between separate session .
Like & Session('bdr_fac_cntemail') & Session('fac_cntemail') & Session('bdr_fac_cntemail') & Session('fac_cntemail') & etc
Not
& Session('bdr_fac_cntemail') Session('fac_cntemail') &
I've to write a csv for a third-party upload. They're saying they can't read the csv file created because it has two extra lines of code and doesn't end (when opened in Notepad) on the last character of the last line. That's true - but can anyone tell me why?
Dim _csvLine As New System.IO.StreamWriter(Server.MapPath("~/folder/_" & rptType.SelectedItem.Value.ToString & ".csv"), False)
Dim tb As New StringBuilder
Dim x As Integer = ds.Tables("csv").Columns.Count, y As Integer = 1
For Each row As Data.DataRow In ds.Tables("csv").Rows
For Each col As Data.DataColumn In ds.Tables("csv").Columns
If y <> x Then
tb.Append(Trim(System.Text.RegularExpressions.Regex.Replace(row.Item(col).ToString, "\s+", " ", RegexOptions.IgnoreCase Or RegexOptions.Multiline)) & ",")
y = y + 1
Else
tb.Append(Trim(System.Text.RegularExpressions.Regex.Replace(row.Item(col).ToString, "\s+", " ", RegexOptions.IgnoreCase Or RegexOptions.Multiline)))
tb.AppendLine()
y = 1
End If
Next
Next
_csvLine.WriteLine(Left(tb.ToString, Len(tb.ToString) - 2))
_csvLine.Flush()
_csvLine.Close()
_csvLine.Dispose()
One line is appended by _csvLine.WriteLine, use Write() instead.
tb.AppendLine() adds the second line, try avoiding it on the last line.
You're doing _csvLine.WriteLine( which is gonna add a linebreak to the end of the file.
Hello there I'm trying to get a date in ASP to show up in a particular format (yyyymmdd). This is what I've tried so far but no luck. Any help is appreciated. Thanks
<tr>
<td><b>Call Date</b></td>
<% for i = -6 to 0 %>
<td align=center>
X
</td>
<% Next %>
</tr>
You can make use of the following functions:
Year(Now) '' Year in 4 digits
Month(Now) '' Month without leading zero
Day(Now) '' Day of the month without leading zero
DateAdd("d", <numofdays>, Now) '' add a number of days to your date
Read more about these (and other date functions) functions here.
If you need to add a leading zero:
function addLeadingZero(value)
addLeadingZero = value
if value < 10 then
addLeadingZero = "0" & value
end if
end function
An example of your case would be:
Dim today, myDate
today = Now
for i = -6 to 0
myDate = DateAdd("d", i, today)
response.write "X"
next
Sorry to dig this up, but it might be of help to some people. Rather than the "If<10 then add leading zero" logic, I often use the right command and always add a leading zero...
response.write "X"
..This way, you don't need a separate function, and it can be done on one line. I can't speak for the efficiency of it, but it seems logical.
ASP gets the date from the OS not from the Database, a common error, but it is solved by use:
<%
' Date dd/mm/yyyy
Session.lcid=2057 '= UK English
%>
I hope it helps people.
You can try. 100% tested!
<%
mm = Month(now())
dd = Day(now())
yy = Year(now())
IF len(mm) = 1 THEN
mm = "0" & mm
END IF
IF len(dd) = 1 THEN
dd = "0" & dd
END IF
response.write(yy & "/" & mm & "/" & dd)
%>
<%= DatePart("yyyy", Now) & "/" & DatePart("m", Now) & "/" & DatePart("d", Now) %>
Also refer
http://www.w3schools.com/vbscript/vbscript_ref_functions.asp
http://www.mikesdotnetting.com/Article/22/Date-formatting-in-VBScript
Thanks
Deepu
Mid(date(), 7,4) & "-" & Mid(date(), 4,2) & "-" & Left(date(), 2)
For an equation, mathjax renders like as shown in image. Please help me to find the problem and fix. In codecogs latex editor, this is rendered properly. In MathType equation editor also it displays well.
Actual code follows.
\begin{align}f(x) &= Sin\: [\pi ]x-Sin[\pi ^{2}]x+Cos[-\pi ^{3}]x \\\\
[\pi ] &=[3.14]=3\\\\ [\pi ^{2}]&=[9.8596]=9\\\\
[-\pi ^{3}]&=[-9.8596]=-10 \\\\
f(\frac{\pi }{6}) &= Sin(3\times \frac{\pi }{6})-Sin(9\times \frac{\pi }
{6})+Cos(-10\times \frac{\pi }{6})\\\\
&=Sin\frac{\pi }{2}-Sin\frac{3\pi }{2}+Cos(\frac{5\pi }{3})\\\\
&= 1-\left ( -1 \right )+\frac{1}{2}\\\\
& =2+\frac{1}{2}\\\\
&=\frac{5}{2} \end{align}
It seems the character [ is causing some problem with align environment and MathJax.
This seems to work for me (at least on JaxEdit and http://math.stackexchange.com):
\begin{align}
f(x) & = Sin(\pi)x - Sin(\pi^2)x + Cos(-\pi^3)*x \\
\left[\pi\right] & = \left[3.14\right] = 3 \\
\left[\pi ^{2}\right] & = \left[9.8596\right]=9 \\
\left[-\pi ^{3}\right] & = \left[-9.8596\right]=-10 \\
f(\frac{\pi }{6}) & = Sin(3\times \frac{\pi }{6})-Sin(9\times \frac{\pi}{6})+Cos(-10\times \frac{\pi }{6})\\
& = Sin\frac{\pi }{2}-Sin\frac{3\pi }{2}+Cos(\frac{5\pi }{3})\\
& = 1-\left ( -1 \right )+\frac{1}{2}\\
& = 2+\frac{1}{2}\\
& = \frac{5}{2}
\end{align}
Or use an equivalent symbole from one of the package that is installed with your MathJax solution