Getting Vb.net code for Tagging system RRS feed

  • Question

  • User-786564416 posted

    I got the following c-sharp code and I want to get its vb.net correspondent. I got it from the  https://www.codeproject.com/Tips/789293/Creating-a-Tagging-System-using-ASP-net-implementi source

    The c-sharp code is as following:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data.SqlClient;
    using System.Web.Services;
    using System.Data;
    using System.Text;
    using System.Configuration;
    public partial class tag : System.Web.UI.Page
        BusinessLayer ob = new BusinessLayer();
        SqlConnection conn;
        public string listFilter = null;
        public string listFilter_for_parts = null;
        StringBuilder output_part = new StringBuilder();
        protected void Page_Load(object sender, EventArgs e)
            listFilter = BindName();
            listFilter_for_parts = output_part.ToString();      
        protected void Button1_Click(object sender, EventArgs e)
            string input_tags = singleFieldTags2.Text;
            string[] tags_input_parts = input_tags.Split(',');
            string[] database_tags = listFilter_for_parts.Split(',');
            foreach (string input in tags_input_parts)
                foreach (string database in database_tags)
                    if (input == database)
                        goto OUTERCONTINUE; 
                ob.ExecuteScalar("exec tag_insert @tag_name='"+input+"' ");
             OUTERCONTINUE: ;
        private string BindName()
            DataTable dt = null;
            using (conn = new SqlConnection
                using (SqlCommand cmd = conn.CreateCommand())
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "select tag_name from tags";
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        dt = new DataTable();
            StringBuilder output = new StringBuilder();
            for (int i = 0; i < dt.Rows.Count; ++i)
                output.Append("\"" + dt.Rows[i]["tag_name"].ToString() + "\"");
                if (i != (dt.Rows.Count - 1))
            return output.ToString();

    I need to  have the vb.net working code, with thanks.

    Thursday, September 20, 2018 8:07 PM

All replies

  • User2053451246 posted

    Converted by http://converter.telerik.com/

    Imports System
    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Web
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
    Imports System.Data.SqlClient
    Imports System.Web.Services
    Imports System.Data
    Imports System.Text
    Imports System.Configuration
    Public Partial Class tag
        Inherits System.Web.UI.Page
        Private ob As BusinessLayer = New BusinessLayer()
        Private conn As SqlConnection
        Public listFilter As String = Nothing
        Public listFilter_for_parts As String = Nothing
        Private output_part As StringBuilder = New StringBuilder()
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            listFilter = BindName()
            listFilter_for_parts = output_part.ToString()
        End Sub
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim input_tags As String = singleFieldTags2.Text
            Dim tags_input_parts As String() = input_tags.Split(","c)
            Dim database_tags As String() = listFilter_for_parts.Split(","c)
            For Each input As String In tags_input_parts
                For Each database As String In database_tags
                    If input = database Then
                        GoTo OUTERCONTINUE
                    End If
                ob.ExecuteScalar("exec tag_insert @tag_name='" & input & "' ")
        End Sub
        Private Function BindName() As String
            Dim dt As DataTable = Nothing
            Using CSharpImpl.__Assign(conn, New SqlConnection(ConfigurationManager.ConnectionStrings("mystpcon").ConnectionString))
                Using cmd As SqlCommand = conn.CreateCommand()
                    cmd.CommandType = CommandType.Text
                    cmd.CommandText = "select tag_name from tags"
                    Using da As SqlDataAdapter = New SqlDataAdapter(cmd)
                        dt = New DataTable()
                    End Using
                End Using
            End Using
            Dim output As StringBuilder = New StringBuilder()
            For i As Integer = 0 To dt.Rows.Count - 1
                output.Append("""" & dt.Rows(i)("tag_name").ToString() & """")
                If i <> (dt.Rows.Count - 1) Then
                End If
            Return output.ToString()
        End Function
        Private Class CSharpImpl
            <Obsolete("Please refactor calling code to use normal Visual Basic assignment")>
            Shared Function __Assign(Of T)(ByRef target As T, value As T) As T
                target = value
                Return value
            End Function
        End Class
    End Class

    Thursday, September 20, 2018 8:29 PM