Posts tagged Visual Basic.Net

Split Command Sample Code (VB NET)

0

Preparations : 1 Textbox and 1 Button

Code :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
    Dim strInput As Array 'make array variable
 
    Dim strResult1 As String 'text variable
 
    Dim strResult2 As String 'another text variable
 
    Try
 
    strInput = Split(TextBox1.Text, " ")
 
    'split the textbox if there is space.
 
    'you can also use chr(32) to replace " "
 
    strResult1 = strInput(0) 'split first text
 
    strResult2 = strInput(1) 'split second text
 
    MsgBox(strResult1 + strResult2)
 
    'combine first and second text with no space
 
    Catch ex As Exception
 
    End Try
 
    End Sub

Test the code, type space character between 2 words :

What we have done here?

Explanation :

  1. We have 2 words with a space character (“jenni” and “fer”)
  2. We split those words using “Split” command into array, the process is identified with space character, so we had 2 lines.
  3. We combine those words back together in one line, but this time with no space character in it.

Progress Bar Sample Code (VB NET 2008)

0

Picture Info:

—————————–

(A) Progress Bar, Properties :

Name = ProgressBar1

Minimum (value) = 0

Maximum (value) = 100

(B) Button, Properties :

Name = Button1

Text = Button1

(C) Timer, Properties:

Name = Timer1

Enabled = False

Interval = 100

Kode (F7) :

—————-

Public Class Form1
Private Sub Timer1_Tick(ByVal sender As  System.Object, ByVal e As  System.EventArgs)Handles Timer1.Tick
 
Static TikTok As Integer
 
TikTok = TikTok + 1
 
ProgressBar1.Value = TikTok
 
If ProgressBar1.Value = ProgressBar1.Maximum  Then
Timer1.Enabled  = False 'deactivate Timer1
 
TikTok  = 0 'set static value back to 0
End If
 
End Sub
 
Private  Sub Button1_Click(ByVal sender As System.Object, ByVal e As  System.EventArgs)Handles Button1.Click
Timer1.Enabled = True 'activate Timer1
 
Timer1.Interval = 100 'set interval to 100
 
ProgressBar1.Value = 0 'set ProgressBar value  to 0
End Sub
 
End Class

Hacking the Report Viewer Redistributable

0

We always face a problem when we want to publish an application, we want to make sure not to make the customer go through Library installation & dll’s & ocx’s registration, the ideal scenario is to give the customer a portable application that does not need any configuration of course that is hard to achieve especially when you have databases that need servers but you can do that with small to medium sized applications.

error

error

Today i’m going to address a different problem i faced on one of the projects i’m working on currently. I thought of using report viewer included in visual studio 2008 & 2005 keeping away from crystal reports, thinking that microsoft report viewer is included in the .net framework which turned out to be wrong.

Microsoft includes the pack for this as a standalone installation found here:

Microsoft Report Viewer Redistributable 2005 Service Pack 1:

http://www.microsoft.com/downloads/details.aspx?FamilyID=82833F27-081D-4B72-83EF-2836360A904D&displaylang=en

Microsoft Report Viewer Redistributable 2008 Service Pack 1:

http://www.microsoft.com/downloadS/details.aspx?familyid=BB196D5D-76C2-4A0E-9458-267D22B6AAC6&displaylang=en

Next use any of your zip extraction program to extract the ReportViewer.exe

You will see a CAB file named vb_ros.cab also extract it.

————————————————————————————————————————————–

Then do as following:

  1. Rename: FL_Microsoft_ReportViewer_Common_dll_117718_____X86.3643236F_FC70_11D3_A536_0090278A1BB8 To Microsoft.ReportViewer.Common.dll
  2. Rename: FL_Microsoft_ReportViewer_ProcessingObject_125592_____X86.3643236F_FC70_11D3_A536_0090278A1BB8 To Microsoft.ReportViewer.ProcessingObjectModel.dll
  3. Rename: FL_Microsoft_ReportViewer_WebForms_dll_117720_____X86.3643236F_FC70_11D3_A536_0090278A1BB8 To Microsoft.ReportViewer.WebForms.dll
  4. Rename: FL_Microsoft_ReportViewer_WinForms_dll_117722_____X86.3643236F_FC70_11D3_A536_0090278A1BB8 To Microsoft.ReportViewer.WinForms.dll

Now go to your project.

copy paste the renamed dlls, next to your exe file for exapmple “Myproject\bin\..”

now right click on your project, press properties.

go to references tab

press add -> reference -> browse -> choose the 4 dll’s

That’s it, now your project can work as a portable standalone project with report viewer support.

Thank you for reading.

Please check the youtube video if you like a more step by step tutorial

Go to Top