Different result in ASP than in VBScript - asp-classic

If I run following code in VBScript all works as expected, if i run it in ASP (IIS 7) the I get this wrong result. Does anyone know why?
mumber = "027609366"
WScript.Echo Left(number, 2) & " " & _
Mid(number, 3, 2) & " " & _
Mid(number, 5, 2) & " " & _
Right(number, 3)
' vbs => 03 76 09 366 (right)
' asp => 03 76 09 66 (wrong)
I now use the following which works:
Left(number, 2) & " " & _
Mid(number, 3, 2) & " " & _
Mid(number, 5, 2) & " " & _
Mid(number, 7)
But i wonder why this happens.

ASP code is written using VBScript, so the results can't be different, as they are technically the same thing.
Is there an extra space on the end of one of your numbers somewhere, that could be causing the number to be displayed incorrectly?

Related

EPOC date to Normal system date in VBS

I have read many post but nothing really helped.
My question looks similar but bit different.
I have to change EPOC time to system time format.
data type = datetime
value= 20160630165419.634204+060
desired output
data type = datetime
value= 30/06/2016 16:54:19
as the EPOC value has digits after dot and the datatype is datetime , which makes it difficult to divide it by 10 in a loop and get ingteral value.
Please suggest solution for given input format only.
You can use this function WMIDateStringToDate for converting your date :
WScript.echo WMIDateStringToDate("20160227235343.000000+060")
WScript.echo WMIDateStringToDate("20160630165419.634204+060")
'************************************************************
Function WMIDateStringToDate(Mydate)
WMIDateStringToDate = CDate(Mid(Mydate, 5, 2) & "/" & _
Mid(Mydate, 7, 2) & "/" & Left(Mydate, 4) _
& " " & Mid (Mydate, 9, 2) & ":" & _
Mid(Mydate, 11, 2) & ":" & Mid(Mydate,13, 2))
End Function
'************************************************************
Step 1: use DateSerial() and TimeSerial() on numbers (CInt()) extracted from your input (Mid()) to get a variant of subtype Date
Step 2: use SetLocale() and Replace() to format/stringify the Date
>> SetLocale "de-de"
>> sX = "20160630165419.634204+060"
>> dtD = DateSerial(CInt(Mid(sX, 1, 4)), CInt(Mid(sX, 5, 2)), CInt(Mid(sX, 7, 2)))
>> dtT = TimeSerial(CInt(Mid(sX, 9, 2)), CInt(Mid(sX, 11, 2)), CInt(Mid(sX, 13,2)))
>> dtX = dtD + dtT
>> WScript.Echo dtX, TypeName(dtX)
>> WScript.Echo Replace(dtX, ".", "/")
>>
30.06.2016 16:54:19 Date
30/06/2016 16:54:19
Danger, Will Robinson! Look at this test script:
Function WMIDateStringToDate(Mydate)
WMIDateStringToDate = CDate(Mid(Mydate, 5, 2) & "/" & _
Mid(Mydate, 7, 2) & "/" & Left(Mydate, 4) _
& " " & Mid (Mydate, 9, 2) & ":" & _
Mid(Mydate, 11, 2) & ":" & Mid(Mydate,13, 2))
End Function
'************************************************************
For Each sLocale In Split("de-de en-us")
SetLocale sLocale
For Each sDate In Split("20160227235343.000000+060 20160203235343.000000+060")
On Error Resume Next
dtX = WMIDateStringToDate(sDate)
If Err.Number Then dtX = Err.Description
On Error GoTo 0
WScript.Echo GetLocale(), sD, sDate, dtX
Next
Next
and its output:
cscript 38249865.vbs
1031 20160227235343.000000+060 27.02.2016 23:53:43
1031 20160203235343.000000+060 02.03.2016 23:53:43
1033 20160227235343.000000+060 27.02.2016 23:53:43
1033 20160203235343.000000+060 03.02.2016 23:53:43
to see the reason for:
The sample scripts are not supported under any Microsoft standard
support program or service. The sample scripts are provided AS IS
without warranty of any kind. Microsoft further disclaims all implied
warranties including, without limitation, any implied warranties of
merchantability or of fitness for a particular purpose. The entire
risk arising out of the use or performance of the sample scripts and
documentation remains with you. In no event shall Microsoft, its
authors, or anyone else involved in the creation, production, or
delivery of the scripts be liable for any damages whatsoever
(including, without limitation, damages for loss of business profits,
business interruption, loss of business information, or other
pecuniary loss) arising out of the use of or inability to use the
sample scripts or documentation, even if Microsoft has been advised of
the possibility of such damages.
(found here)

How to convert one date/time format to another from querystring?

I'm getting "August 22, 2015 10:55" in a querystring and I want to convert it to "2015-08-22 10:55".
I have this so far:
datum=request.querystring("tid")
response.write datum ----this writes out August 22, 2015 10:55
datum=Cstr(datum)
DateVar = datevalue(datum)
NewDateVar = year(DateVar) & "-" & month(DateVar) & "-" & day(DateVar)
NewTimeVar=timevalue(datum)
newdatum = NewDateVar & " " & NewTimeVar
But now I get a type missmatch error on DateVar = datevalue(datum).
If I use datum="August 22, 2015 10:55" to test with, then it works.
To spell it out:
>> s = "August 22, 2015 10:55"
>> d = CDate(s)
>> WScript.Echo TypeName(d), d
>>
Date 22.08.2015 10:55:00 <-- german locale!
Added:
To get the required format, you can use the strategy described here.
DateVar = datevalue("August 22, 2015 10:55")
NewDateVar = year(DateVar) & "-" & month(DateVar) & "-" & day(DateVar) & "-" & time(DateVar)
Classic ASP tends to use US date formats, come hell or high water. However, it's easy enough to format the date you display (or pass on to the database) in whatever way you wish.
The following will pad any single-digit values with a 0. If you don't need that, then just use the plain functions, without Right().
Dim datum, mm, dd, yyyy, hh, nn, fdatum
datum = Request.Querystring("tid")
If IsDate(datum) Then
datum = CDate(datum)
mm = Right(100 + Month(datum),2)
dd = Right(100 + Day(datum),2)
yyyy = Year(datum)
hh = Right(100 + Hour(datum),2)
nn = Right(100 + Minute(datum),2)
fdatum = yyyy & "-" & mm & "-" & dd & " " & hh & ":" & nn
Else
fdatum = datum '- or whatever fallback value you want
End If

Expression Expected Error - string assign value

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') &

Mathjax rendering issue

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

How to do the square root in PowerPoint VBA?

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

Resources