codice:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="a.aspx.vb" Inherits="corso_apogeo.a"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>a</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></P>
<asp:Label id="Label1" runat="server"></asp:Label></P>
<HR width="100%" SIZE="1">
<asp:Label id="Label2" runat="server"></asp:Label>
</form>
</body>
</HTML>
codice:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s$ = ""
s += "Arma virumque cano Trojae qui primus ab oris" + vbNewLine
s += "Italiam, fato profugus, Lavinaque venit" + vbNewLine
s += "Littora: multum ille et terris jactatus et alto," + vbNewLine
s += "Vi Superum, saevae memorem Junonis ob iram;" + vbNewLine
Me.Label1.Text = "<pre>" + s + "</pre>"
Dim re As New Regex("\w+\b")
Dim mc As MatchCollection = re.Matches(s)
Dim max% = 10
If mc.Count < max Then max = mc.Count
For i As Integer = 1 To max
Me.Label2.Text += mc(i - 1).Value + " "
Next
End Sub