Answered by:
Help with vb and aspx

Question
-
User-1487998073 posted
Can someone please help with these:
<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage(Of Movies.Movies.HelloWorldController+WelcomeViewModel)" %><asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">Welcome</asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"><h2>Welcome Teste</h2><% For i As Integer = 0 To i > Model.NumTimes Step 1%><h3> <%: Model.Message + " " + i.ToString + " - " + Model.NumTimes.ToString%></h3><%Next i%></asp:Content><%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage(Of Movies.Movies.HelloWorldController+WelcomeViewModel)" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Welcome </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Welcome Teste</h2> <% For i As Integer = 0 To i > Model.NumTimes Step 1 %> <h3> <%: Model.Message%></h3> <% Next i %> </asp:Content>
I'm trying to follow the starter tutorial but doing it in VB and i can't understand why my For loop isn't working.
Tkx in advance.
RD
Wednesday, September 29, 2010 10:33 AM
Answers
-
User-1828494216 posted
For index=start to end[Step step]
[statements]
[Exit For]
[statements]
Next[index]<% For i = 0 To Model.NumTimes %>
<h3> <%: Model.Message%></h3>
<% Next %>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 29, 2010 10:54 AM -
User-660870441 posted
Hi,
As mitja.GTI said, the For-Loop statement is not correct. Please use this code to replace yours.
<% For i = 0 To Model.NumTimes %> <h3> <%: Model.Message %></h3> <% Next %>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, October 4, 2010 9:48 PM
All replies
-
User-1828494216 posted
For index=start to end[Step step]
[statements]
[Exit For]
[statements]
Next[index]<% For i = 0 To Model.NumTimes %>
<h3> <%: Model.Message%></h3>
<% Next %>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 29, 2010 10:54 AM -
User-1487998073 posted
Tkx for the help but still not working.
If I open the browser with the address: http://localhost:xxxx/HelloWorld/Welcome?name=Ricardo&numtimes=3
It was supposed to write my name 3 times. And i get only 1. Debugging the code I get that it enters the for loop but does not repeat the code 3 times.
RD
Wednesday, September 29, 2010 11:18 AM -
User-1828494216 posted
and what value is in Model.NumTimes?
Wednesday, September 29, 2010 11:53 AM -
User-1487998073 posted
In the above example 3
http://localhost:54329/HelloWorld/Welcome?name=Ricardo&numtimes=3
RD
Wednesday, September 29, 2010 11:58 AM -
User-1828494216 posted
no, when you are debugging... what value does it acctually holdes
Wednesday, September 29, 2010 12:14 PM -
User-1487998073 posted
Kinda have problems knowing that in debugging (tried add a watch but no do). Doing this:
<% For i As Integer = 0 To i > Model.NumTimes %> <h3> <%: Model..Message + " - " + Model.NumTimes.tostring %></h3> <% Next%>
Hello Ricardo - 3
RD
Wednesday, September 29, 2010 12:26 PM -
User-660870441 posted
Hi,
As mitja.GTI said, the For-Loop statement is not correct. Please use this code to replace yours.
<% For i = 0 To Model.NumTimes %> <h3> <%: Model.Message %></h3> <% Next %>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, October 4, 2010 9:48 PM -
User-1487998073 posted
First tkx. This way works perfectly but please help understand this.
Why does this work:
<% For i = 0 To Model.NumTimes%> <h3> <%: Model.Message%></h3> <% Next%>
And this not:<% For i As Integer = 0 To i> Model.NumTimes%> <h3> <%: Model.Message%></h3> <% Next%>
Or even this:<% For i As Integer = 0 To i> Model.NumTimes% step 1> <h3> <%: Model.Message%></h3> <% Next i%>
I'm very frustrated with this. I think it's a simple thing but can't get it...
Tkx one more time to all.
RD
Wednesday, October 6, 2010 6:52 AM