-2

I am a PLC programmer, not a .ASP guy, and don’t know how to write the code for getting the result I need. I have a PLC tag I read for my web display, but I would like to show only the first two numbers after the decimal point. I don’t know if I can format the body to do that.

This is my code:

<td align="left" height="24" style="width: 262px"><b>NF1:<% ReadLogixTagUnconnecte("1,0","NF1_FT14101", "REAL");%>GPM</b></td>

This is how it displays now: NF1:15.2013 This is what I will like to have: NF1:15.20

I tried the following but it will not even show a value:

<td align="left" height="24" style="width: 262px"><b>NF1:<% ReadLogixTagUnconnected("1,0","NF1_FT14101", "REAL");%>.TOSTRING(0.00)>GPM</b></td>
bg.dev
  • 68
  • 7
Vic
  • 1

1 Answers1

0

EDITED 2 This is for classic asp:

<td align="left" height="24" style="width: 262px"><b>NF1:<% FormatNumber(ReadLogixTagUnconnected("1,0","NF1_FT14101", "REAL"), 2); %>GPM</b></td>

Please post it at the right place next time

EDITED: Try

<td align="left" height="24" style="width: 262px"><b>NF1:<% Response.Write(string.Format("{0:N2}", ReadLogixTagUnconnected("1,0","NF1_FT14101", "REAL")));%>GPM</b></td>

For more info about numeric formatting: http://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx

Format string: http://msdn.microsoft.com/en-us/library/system.string.format(v=vs.110).aspx

bg.dev
  • 68
  • 7
  • After trying your suggestion I get This error ASP Error: Undefined variable Response At line 1, line => Response.Write( – Vic Jul 10 '14 at 21:44
  • there's a typo error in the code I posted: "**ReadLogixTagUnconnecte**" (missing 'd' at the end), did you fix that? If yes I see no reason why it doesn't work. <% Response.Write(string.Format("{0:N2}", ReadLogixTagUnconnected("1,0","NF1_FT14101", "REAL")));%> – bg.dev Jul 12 '14 at 08:24
  • bg.dev I did notice the "d missing but that doesn't look is what is causing the issue NF1 Stage 1:<%(Response.Write(string.Format("{0:N2}", ReadLogixTagUnconnected("1,0","NF1_FT14101", "REAL"))); %> GPM and this is the Error I get ASP Error: Undefined variable Response At line 1, line => (Response.Write( this the way is written do you see something I am missing? – Vic Jul 14 '14 at 21:33
  • Can you post all your page code? Try System.Web.HttpContext.Current.Response.Write Or try <%Response.Write(string.Format("{0:N2}", 1000)); %> to see if it outputs a number on your page. – bg.dev Jul 14 '14 at 21:47
  • So I will try to post the page code but I did try your test in this what I get ASP Error: Undefined variable Response At line 1, line => (Response.Write( (Response.Write(string.Format("{0:N2}",10000)); – Vic Jul 16 '14 at 14:59
  • oh, you are talking about classic ASP, aren't you? I thought you're using .NET. Try FormatNumber(ReadLogixTagUnconnected("1,0","NF1_FT14101", "REAL"), 2) instead. See the edited answer. – bg.dev Jul 17 '14 at 16:20
  • you are correct it is old ASP we use Microsoft office share point Designer and that is as much as I know abut this I am a PLC programmer. I must not know hot to post the page I tried to copy and past and it gives me a to long characters. I tryed a difrent tag from the PLC this is the way it sits now, but it still gives me a error "undefined procedure Ratio:<%FormatNumber(ReadLogixTagUnconnected("1,0","UF2Ratio", "REAL")2);%> – Vic Jul 18 '14 at 13:14
  • I'm not familiar with classic asp, so I'll just edit the tag to asp-classic. See if you can have any help from there. btw, you missed the comma in the code you've just posted. – bg.dev Jul 18 '14 at 18:43