web 2.0

VB.NET & CType()

VB.NET & CType() - CType() : Returns the result of explicitly converting an expression to a specified data type, object, structure, class, or interface.

ShotDev Focus:
- VB.NET & CType()

Example

CType.aspx

  1. <%@ Page Language="VB" %>  
  2. <script runat="server">  
  3.   
  4. Sub Page_Load(sender As Object, e As EventArgs)  
  5. Dim i As Integer  
  6. For i = 1 To 4  
  7. Dim lblLabel = CType(Me.FindControl("lblText"&i),Label)  
  8. IF Not IsNothing(lblLabel) Then  
  9. lblLabel.Text = "www.ShotDev.Com " & i  
  10. End IF  
  11. Next  
  12. End Sub  
  13.   
  14. </script>  
  15. <html>  
  16. <head>  
  17. <title>ShotDev.Com Tutorial</title>  
  18. </head>  
  19. <body>  
  20. <form runat="server">  
  21. <asp:Label id="lblText1" runat="server"></asp:Label><br />  
  22. <asp:Label id="lblText2" runat="server"></asp:Label><br />  
  23. <asp:Label id="lblText3" runat="server"></asp:Label><br />  
  24. <asp:Label id="lblText4" runat="server"></asp:Label><br />  
  25. </form>  
  26. </body>  
  27. </html>  

Screenshot

VB.NET & CType()
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.