My code

  • Hi here is my code....

    ' Microsoft SQL Server Integration Services Script Task

    ' Write scripts using Microsoft Visual Basic 2008.

    ' The ScriptMain is the entry point class of the script.

    Imports System

    Imports System.Data

    Imports System.Math

    Imports System.IO

    Imports Microsoft.SqlServer.Dts.Runtime

    <System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _

    <System.CLSCompliantAttribute(False)> _

    Partial Public Class ScriptMain

    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase

    Enum ScriptResults

    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success

    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure

    End Enum

    Dim oFile As System.IO.File

    Dim oRead As System.IO.StreamReader

    Dim oWrite As System.IO.StreamWriter

    Dim A As String

    Dim Ctr As Integer = 0

    Dim i As Integer = 1

    Dim j As Integer = ""

    Dim N1 As Integer = 75

    Dim N2 As Integer = 150

    Dim str As String = ""

    Dim str1 As String = ""

    Dim str2 As String = ""

    Dim str3 As String = ""

    Dim str4 As String = ""

    Public Sub Main()

    oWrite = IO.File.CreateText("E:\Script\LoveLace_output.txt")

    oRead = IO.File.OpenText("E:\Script\LoveLace\Source.txt")

    While oRead.Peek <> -1

    A = oRead.ReadLine()

    j = CInt(Round(A.Length / N2)) + 1

    'MsgBox(A.Length)

    For Me.i = 1 To j

    If (A.Length > N1) Then

    If i = 1 Or (i Mod 7) = 1 Then

    str = A.Substring(0, N1)

    Ctr += 1

    oWrite.WriteLine("TOG N1 " & str)

    'oWrite.WriteLine(str)

    'MsgBox(str.Length)

    'A = A.Substring(N1 + 1, A.Length - N1)

    A = A.Substring(N1)

    Else

    If (A.Length > N2) Then

    str1 = A.Substring(0, N2)

    Ctr += 1

    oWrite.WriteLine(str1)

    'MsgBox(str1.Length)

    A = A.Substring(N2)

    Else

    str2 = A.Substring(0, A.Length)

    Ctr += 1

    oWrite.WriteLine(str2)

    If A.Length > N2 Then

    A = A.Substring(N2)

    End If

    'MsgBox(str2.Length)

    End If

    End If

    End If

    Next

    If A.Length <= N1 And A.Length > 0 Then

    str4 = A.Substring(0, A.Length)

    'oWrite.WriteLine(str4)

    If Ctr = 0 Or Ctr Mod 7 = 0 Then

    oWrite.WriteLine("TOG N1 " & str4)

    Else

    oWrite.WriteLine(str4)

    End If

    'MsgBox(str4.Length)

    End If

    Ctr = 0

    End While

    oWrite.Close()

    Dts.TaskResult = ScriptResults.Success

    End Sub

    End Class

    Thanks & Regards,
    Shriram.

  • That's nice. What's the point?

  • it May be nice, but it would be even nicer if it was in a more concise and readable language like C#.

    but I digress...

    The probability of survival is inversely proportional to the angle of arrival.

  • sturner (12/21/2009)


    it May be nice, but it would be even nicer if it was in a more concise and readable language like C#.

    but I digress...

    Nothing wrong with VB.NET, but let's not get into the religous wars between the two languages.

  • shriramrc 75244 (12/21/2009)


    Hi here is my code....

    So what? We've known for years that the answer is 42.

    β€œWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • Chris Morris-439714 (12/21/2009)


    So what? We've known for years that the answer is 42.

    Yes, but what is the actual question? πŸ™‚

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

  • Ray K (12/21/2009)


    Chris Morris-439714 (12/21/2009)


    So what? We've known for years that the answer is 42.

    Yes, but what is the actual question? πŸ™‚

    Rumour has it that someone is deep in thought over that one 😎

    β€œWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply