0% found this document useful (0 votes)
3 views12 pages

Sample Coding

Uploaded by

gs admin
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views12 pages

Sample Coding

Uploaded by

gs admin
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Imports System.

IO
Public Class Frm_encode

Dim cn As New [Link]


Dim rs As New [Link]
Dim dynaStrings() As String
Dim gen_string() As String
Dim dystrings() As String
Dim s1, s2, s3, s4 As String
Dim space_strings() As String
Dim i As Long
Dim j As Long
Dim temp As Integer
Dim z As Long
Dim perarr() As String
Dim ztring As String
Dim permutestring As String
Dim TmpStrArray() As String
Dim base As String

Private Sub Frm_encode_Load(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
cn = New [Link]
[Link]("Provider=SQLOLEDB;Data
Source=PRAVEEN\SQLEXPRESS;Integrated Security=SSPI;Initial
Catalog=Genpacknew")
Call load_id()
End Sub

Public Sub load_id()


cbo_id.[Link]()
rs = New [Link]
[Link]("Select * from gen_master", cn,
[Link], [Link])
If [Link] = True Then Exit Sub
While Not [Link]
cbo_id.[Link]([Link](0).Value)
[Link]()
End While
[Link]()
End Sub

Private Sub cbo_id_SelectedIndexChanged(ByVal sender As


[Link], ByVal e As [Link]) Handles
cbo_id.SelectedIndexChanged
On Error Resume Next
rs = New [Link]
[Link]("select * from gen_master where gen_id = " & cbo_id.Text
& "", cn, [Link],
[Link])
If [Link] = True Then Exit Sub
[Link] = [Link](1).Value
txt_original.Text = [Link]
Dim sr As New StreamReader([Link],
[Link].UTF8)
txt_original.Text = [Link]()
[Link]()
Dim fFile As New FileInfo([Link])
Dim fSize As Integer = [Link]
original_size.Text = [Link] & " bytes"
lbl_char.Text = RTrim(txt_original.[Link]) & " Characters"
Call create_array()
Call split_chars_into_array()
End Sub

Public Sub space_in_array()


j = 0
For i = 0 To [Link] - 2
If dynaStrings(i) = " " Then
space_strings(j) = i
j = j + 1

End If
Next
calc_space = j
Dim l As Long
l = [Link] - 1
l = 0
Dim z As Integer
For z = 0 To lv_encode.[Link] - 1
l = l + 1
If lv_encode.Items(z).Text = " " Then
lv_encode.Items(z).UseItemStyleForSubItems = False
lv_encode.Items(z).BackColor = [Link]
Dim k As Integer
For k = 0 To 499
l = l + 1
If l >= [Link] - 1 Then
Exit Sub
End If
If lv_encode.Items(z).SubItems(k).Text = " " Then
lv_encode.Items(z).UseItemStyleForSubItems =
False
lv_encode.Items(z).SubItems(k).BackColor =
[Link]
End If
Next k
Else
Dim k As Integer
For k = 0 To 499
l = l + 1
If l >= [Link] - 1 Then
Exit Sub
End If
If lv_encode.Items(z).SubItems(k).Text = " " Then
lv_encode.Items(z).UseItemStyleForSubItems =
False
lv_encode.Items(z).SubItems(k).BackColor =
[Link]
End If
Next k
End If
Next z
End Sub

Public Sub split_chars_into_array()


For i = 0 To [Link] - 2
dynaStrings(i) = txt_original.[Link](i, 1)
Next (i)

lv_encode.Clear()
Dim k As Integer
For k = 0 To 499
lv_encode.[Link]("", 20)
Next

Dim r As Integer
r = 0
Dim z As Long
For z = 0 To [Link] - 1
a: If z >= [Link] - 1 Then
Exit Sub
End If
lv_encode.[Link](dynaStrings(z))
For k = 0 To 499
If z >= [Link] - 1 Then
Exit Sub
End If
z = z + 1
lv_encode.Items(r).[Link](dynaStrings(z))
If k = 499 Then
If z >= [Link] - 1 Then
Exit Sub
End If
k = 0
r = r + 1
z = z + 1
'MsgBox(z)
GoTo a
End If
Next k
Next z
End Sub

Public Sub create_array()


ReDim dynaStrings(txt_original.[Link])
ReDim dystrings([Link])
ReDim space_strings(txt_original.[Link])
End Sub

Private Sub cmd_content_Click(ByVal sender As [Link], ByVal e


As [Link]) Handles cmd_content.Click
s1 = "A"
s2 = "C"
s3 = "T"
s4 = "G"
[Link] = True
ReDim perarr(100)
Call permutation()
End Sub
Public Sub permutation()
'Four Combination
End Sub

Private Sub Button1_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
'removing Unwanted Characters
lv_encode.[Link]()
Dim flag As Boolean
flag = False
Dim arr As Integer
Dim col, row As Integer
col = 0 : row = 0
For arr = 0 To [Link] - 2
If dynaStrings(arr) = " " Then
ElseIf flag = False And dynaStrings(arr) <> " " Then
lv_encode.[Link](dynaStrings(arr))
flag = True
ElseIf flag = True And dynaStrings(arr) <> " " Then
If col = 499 Then
col = 0
flag = False
row = row + 1
Else
lv_encode.Items(row).[Link](dynaStrings(arr))
col = col + 1
End If
End If
Next arr

'Calculate First Encoding stage


'txt_encoding.Text = ""
'Dim l As Integer
'Dim cc As Integer
'cc = 0
'For l = 0 To lv_encode.[Link] - 1
' txt_encoding.Text = txt_encoding.Text &
lv_encode.Items(l).Text
' For cc = 0 To 499
' txt_encoding.Text = txt_encoding.Text &
lv_encode.Items(l).SubItems(cc).Text
' Next cc
'Next l

Dim temp As String


txt_encoding.Text = ""
temp = ""
Dim l As Integer
Dim cc As Integer
cc = 0
For l = 0 To [Link] - 2
If dynaStrings(l) = " " Then
Else
temp = temp & dynaStrings(l)
End If
Next l
txt_encoding.Text = temp
com_char.Text = txt_encoding.[Link] & " Characters"
End Sub

Private Sub Button3_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
Call space_in_array()
End Sub

Private Sub lbl_close_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles lbl_close.Click
[Link] = False
End Sub

Private Sub Button4_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
Call tran_copy()
rs = New [Link]
[Link]("Select * from perma", cn,
[Link], [Link])
While Not [Link]
'MsgBox(cmp_str)
lv_encode.[Link]()
Dim flag As Boolean
flag = False
Dim arr As Integer
Dim col, row As Integer
col = 0 : row = 0
For arr = 0 To [Link] - 2
If dystrings(arr) = " " Then
ElseIf flag = False And dystrings(arr) <> " " Then
lv_encode.[Link](dystrings(arr))
flag = True
ElseIf flag = True And dystrings(arr) <> " " Then
If col = 499 Then
col = 0
flag = False
row = row + 1
Else
lv_encode.Items(row).[Link](dystrings(arr))
col = col + 1
End If
End If
Next arr
cmp_str = Trim([Link](0).Value)
MsgBox(cmp_str & " is going to compress now" & vbNewLine &
"Current Size:" & com_char.Text, [Link], "DNA Sequence
Compression")
If Len(cmp_str) = "4" Then
Call tetra_compress()
ElseIf Len(cmp_str) = "3" Then
Call tri_compress()
ElseIf Len(cmp_str) = "2" Then
Call bi_compress()
End If
[Link]()
End While
[Link]()

End Sub

Public Sub tran_copy()


For i = 0 To [Link] - 2
dystrings(i) = dynaStrings(i)
Next i
End Sub

Public Sub tetra_compress()


Dim t1, t2, t3 As Integer
Dim s1, s2, s3, s4 As String
Dim temp As String
s1 = ""
s2 = ""
s3 = ""
s4 = ""
txt_encoding.Text = ""
temp = ""
Dim l As Integer
Dim temp_l As Integer
Dim cc As Integer
cc = 0
For l = 0 To [Link] - 2
temp_l = l
If dystrings(l) = " " Then
Else
s1 = dystrings(l)
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
a: If dystrings(l) = " " Then
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
GoTo a
Else
s2 = dystrings(l)
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
End If
b: If dystrings(l) = " " Then
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
GoTo b
Else
s3 = dystrings(l)
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
End If
c: If dystrings(l) = " " Then
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
GoTo c
Else
s4 = dystrings(l)
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
End If
l = temp_l
End If
If cmp_str = s1 & s2 & s3 & s4 Then
s1 = ""
s2 = ""
s3 = ""
s4 = ""
If temp_l >= [Link] - 3 Then
GoTo d
End If

dystrings(temp_l) = "."
dystrings(temp_l + 1) = " "
dystrings(temp_l + 2) = " "
dystrings(temp_l + 3) = " "
End If
Next l

lv_encode.[Link]()
Dim flag As Boolean
flag = False
Dim arr As Integer
Dim col, row As Integer
col = 0 : row = 0
For arr = 0 To [Link] - 2
If dystrings(arr) = " " Then
ElseIf flag = False And dystrings(arr) <> " " Then
lv_encode.[Link](dystrings(arr))
flag = True
ElseIf flag = True And dystrings(arr) <> " " Then
If col = 499 Then
col = 0
flag = False
row = row + 1
Else
lv_encode.Items(row).[Link](dystrings(arr))
col = col + 1
End If
End If
Next arr
d: Dim temp1 As String
txt_encoding.Text = ""
temp = ""
Dim l_1 As Integer
Dim cc1 As Integer
cc = 0
For l_1 = 0 To [Link] - 2
If dystrings(l) = " " Then
Else
temp1 = temp1 & dystrings(l_1)
End If
Next l_1
Call random_clear()
End Sub

Public Sub random_clear()


Dim temp As String
txt_encoding.Text = ""
temp = ""
Dim l As Integer
Dim cc As Integer
cc = 0
For l = 0 To [Link] - 2
If dystrings(l) = " " Then
Else
temp = temp & dystrings(l)
End If
Next l
txt_encoding.Text = temp
com_char.Text = txt_encoding.[Link] & " Characters"
End Sub

Public Sub tri_compress()


Dim t1, t2, t3 As Integer
Dim s1, s2, s3 As String
Dim temp As String
s1 = ""
s2 = ""
s3 = ""
txt_encoding.Text = ""
temp = ""
Dim l As Integer
Dim temp_l As Integer
Dim cc As Integer
cc = 0
For l = 0 To [Link] - 2
temp_l = l
If dystrings(l) = " " Then
Else
s1 = dystrings(l)
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
a: If dystrings(l) = " " Then
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
GoTo a
Else
s2 = dystrings(l)
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
End If
b: If dystrings(l) = " " Then
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
GoTo b
Else
s3 = dystrings(l)
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
End If
l = temp_l
End If
If cmp_str = s1 & s2 & s3 Then
s1 = ""
s2 = ""
s3 = ""
If temp_l >= [Link] - 3 Then
GoTo d
End If
dystrings(temp_l) = "."
dystrings(temp_l + 1) = " "
dystrings(temp_l + 2) = " "
End If
Next l

lv_encode.[Link]()
Dim flag As Boolean
flag = False
Dim arr As Integer
Dim col, row As Integer
col = 0 : row = 0
For arr = 0 To [Link] - 2
If dystrings(arr) = " " Then
ElseIf flag = False And dystrings(arr) <> " " Then
lv_encode.[Link](dystrings(arr))
flag = True
ElseIf flag = True And dystrings(arr) <> " " Then
If col = 499 Then
col = 0
flag = False
row = row + 1
Else
lv_encode.Items(row).[Link](dystrings(arr))
col = col + 1
End If
End If
Next arr

d: Dim temp1 As String


txt_encoding.Text = ""
temp = ""
Dim l_1 As Integer
Dim cc1 As Integer
cc = 0
For l_1 = 0 To [Link] - 2
If dystrings(l) = " " Then
Else
temp1 = temp1 & dystrings(l_1)
End If
Next l_1
Call random_clear()
End Sub

Public Sub bi_compress()


Dim t1, t2, t3 As Integer
Dim s1, s2 As String
Dim temp As String
s1 = ""
s2 = ""
txt_encoding.Text = ""
temp = ""
Dim l As Integer
Dim temp_l As Integer
Dim cc As Integer
cc = 0
For l = 0 To [Link] - 2
temp_l = l
If dystrings(l) = " " Then
Else
s1 = dystrings(l)
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
a: If dystrings(l) = " " Then
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
GoTo a
Else
s2 = dystrings(l)
l = l + 1
If l >= [Link] - 2 Then
GoTo d
End If
End If
l = temp_l
End If
If cmp_str = s1 & s2 Then
s1 = ""
s2 = ""
If temp_l >= [Link] - 3 Then
GoTo d
End If
dystrings(temp_l) = "."
dystrings(temp_l + 1) = " "
End If
Next l

lv_encode.[Link]()
Dim flag As Boolean
flag = False
Dim arr As Integer
Dim col, row As Integer
col = 0 : row = 0
For arr = 0 To [Link] - 2
If dystrings(arr) = " " Then
ElseIf flag = False And dystrings(arr) <> " " Then
lv_encode.[Link](dystrings(arr))
flag = True
ElseIf flag = True And dystrings(arr) <> " " Then
If col = 499 Then
col = 0
flag = False
row = row + 1
Else
lv_encode.Items(row).[Link](dystrings(arr))
col = col + 1
End If
End If
Next arr

d: Dim temp1 As String


txt_encoding.Text = ""
temp = ""
Dim l_1 As Integer
Dim cc1 As Integer
cc = 0
For l_1 = 0 To [Link] - 2
If dystrings(l) = " " Then
Else
temp1 = temp1 & dystrings(l_1)
End If
Next l_1
Call random_clear()

End Sub

Private Sub Button2_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
[Link]()
[Link]([Link], txt_encoding.Text)
Dim fFile As New FileInfo([Link])
Dim fSize As Integer = [Link]
encoded_size.Text = [Link] & " bytes"
End Sub

Private Sub Button5_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
Dim flag As Boolean
flag = False
Dim arr As Integer
encoded_size.Text = original_size.Text
com_char.Text = lbl_char.Text
Dim col, row As Integer
col = 0 : row = 0
For arr = 0 To [Link] - 2
If flag = False Then
lv_encode.[Link](dynaStrings(arr))
flag = True
ElseIf flag = True Then
If col = 499 Then
col = 0
flag = False
row = row + 1
Else
lv_encode.Items(row).[Link](dynaStrings(arr))
col = col + 1
End If
End If
Next arr
End Sub
End Class

You might also like