Search VB 2010

Sunday, April 13, 2014

VB 2010 Crystal Reports Errors

Visual Basic Online Course - Crystal Reports for VB2010 Errors and Solutions

Error (1)
Could not load file or assembly 'file:///C:\Program Files\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified. how can solve this error in windows application 
 Solution
Add those lines to your App.Config file located in your VB2010 Solution Explorer Panel
and Run your application again.


Error (2)
Crystal Reports Database Login box. Some time Crystal Reports run perfectly on your machine (Developer Machine) but after deploying it and install it on another Machine, it gives you an error like this :
VB2010 Crystal Reports Database Location Error
 Solution
Add those lines to your Form_Load where the report is being loaded to adjust the Database location (Microsoft Access 2003 Database) :

Error (3)
Crystal Reports 2010 doesn't insert pictures manually. When you try to insert a photo into the Crystal Reports 2010 it doesn't take any action. Inserting pictures in Crystal Reports 2010 doesn't work.
Crystal Reports 2010 is not inserting images in the report
Crystal Reports 2010 is not inserting images in the report
 Solution
I've tried many sites and many solutions but I've never figured out the error pattern, or why does Crystal Reports not letting me insert any photo of any kind (JPEG, JPG, PNG) or resolutions. But I landed on this solution and it is working fine with me, and it seems the only solution I've now :
1) Right-click on the report while in the design
2) Choose Insert, then choose Picture
3) Single Left-click the on the photo you wish to insert
4) Click Open, you will notice the image box appears on the report
5) Place the Image box any where on the report and you will see it there.
- I used to double-click the image in the Dialog Box where I choose the Image but that did not work with me, now when I use 'Open', it is working 'Silly'

Error (4)
Crystal Reports 2010 Logon failed for Microsoft Access 2003/2007/2010 Protected Database with password.
This happens when we try to connect the Crystal Report with MS-Access Database in VB 2010 using the code (Programmatically).
Note that it won't happen we connect the Crystal Report with access protected database using the wizard, we just use the (Jet Database Password) field instead of (Database Password) field to provide the report with your Database Password.
VB 2010 Crystal Report MS-Access Password Protected Database
 But, to do this programmatically using code in VB 2010, you notice you always get "Logon Failed" Error message, using something like this :

And you get this error message :

 Solution
After many trials and tests, I've found out the only solution for this problem is to connect dynamically to Crystal Reports in VB 2010 using code is through the DataSet and DataTable Objects, here is the code to accomplish this :

Here is a full example on :
- Connecting protected MS-Access 2007 database with VB 2010
- Insert Data into Database fields
- Delete Data from Database Table
- Connect Crystal Report with VB 2010 and MS-Access protected Database Programmatically
- Update Crystal report without problems when updating MS-Access protected Database.

Wednesday, February 12, 2014

Visual Basic Online Course - Make sure application is running and installed



Visual Basic Online Course

How to make sure that an Application is Running and Installed

VB 2010 Make sure application is running
Visual Basic Online Course - Tips

When you create a Visual Basic 2010 or generally a VB.Net application that relies on another VB.Net application for example an Updater.exe application, you will have to code both sides in order no to enable the user to run Updater.exe without the existence of the Main application, and in order to do so, you will have to make sure that :
1) Your Main application is Running.
2) Your Main application is Installed.
3) Your Main application does exist in the installation folder.
After making sure of all the above points, then you can compile your updater.exe file with your Main Application knowing that updater.exe won't run alone, especially if you're sending updates to the Main application for the user to receive using Updater.exe.

Here are the code to do so :
1) VB 2010 Get list of all installed applications

2) VB 2010 Get list of all running applications

3) VB 2010 Make sure application exists

Thank you for reading, download VB 2010 Project from here

Here are some online Visual Basic lessons and courses :

Wednesday, February 05, 2014

Visual Basic Online Course - Read Text File

Visual Basic 2010 - How to Read Text File(s)

VB 2010 Read Text Files
VB 2010 Read Text Files
Introduction

In order to read from a Text File then a Text File has to be present (Present = Known Path), the path of a Text File is just like any other path of any file it is String, for example :
C:\Folder\File.txt
The path to the File.txt is (C:\Folder\File-Name.Extension), so the path to the File Text = Path + File-Name + extension. Text Files can be present locally (on the same machine) or from external place (on the web) for example :
ftp://10.0.0.27/Folder/File.txt
As long as this Path is present and accessible then Reading Text File in VB 2010 is just so easy job to do. We can store the path to the Text File into a String variable to use it in our VB 2010 project :
Dim LocalFilePath as String = ("C:\Folder\File.txt")
Dim WebFilePath As String = ("ftp://10.0.0.27/Folder/File.txt")
The problem with Text Files hosted on the web, is that it has to be accessible in order to read it or write it, you have to provide  a User Name and Password to gain access to those files for most of the times because of security issues, unlike reading Text Files from local storage devices, there is no need to provide credentials or authentications to be able to read them.

Reading from Local Text Files in VB 2010

We will use File Reader to read String stored in a Text File,we will use basics of reading Text Files.

1) Create VB 2010 Windows Form Project (WindowsApplication1) and save it to (D:\)
2) Add TextBox (Name : TxtFromFile, MultiLine : True)
3) Create Text File (MyFile.txt) and place it in the project folder
Path to MyFile.txt is (D:\WindowsApplication1\Bin\Debug\)
4) Write to MyFile.txt those two lines :
Hello
Visual Basic Online Course
5) Save and close the file.

Now, the project will :
Open the Text File to read on the Form_Load() event
Displays the String in the TextBox (TxtFromFile)

Code


Here are some online Visual Basic lessons and courses :

Sunday, February 02, 2014

Visual Basic Online Course Fade Image

Fade Image in VB 2010

VB 2010 Fade Image
VB 2010 Fade Image
How to fade image in Visual Basic 2010

It doesn’t matter if you are a photographer or a graphic designer, chances are that you have come across the need to fade or blend images in Visual Basic 2010. You can always use Photoshop to create faded images and then use them in your VB 2010 applications, but as a developer you also have to know what does it take to do so, not just to fade an Image but also as a general, after all it's your job to come up with answers.

In our demonstration here well will use ordinary common tools in VB 2010 to be able to fade an Image.

Project Design
 
VB 2010 Example to Fade Image
VB 2010 Example to Fade Image
Form
Name : Form1
Text : Fade Image in VB 2010
PictureBox
Name : PicToFade
BackColor : Transparent
Dock : Full
Timer
Name : Timer1
Interval : 100

How does it work 

Run the application, click on the PicToFade [PictureBox], it will show the [OpenFileDialog] choose and Image [JPEG] and then notice that it will begin to fade away.

You can alter the code to change the fading values [Alpha from 0 to 1 and DeltaAlpha], you can use a Progressbar control to change the fading values too.

Source Code

Download Source Code
MediaFire.com fade image

Here are some online Visual Basic lessons and courses :

Wednesday, January 15, 2014

Visual Basic 2010 Read/Write Command Prompt

Visual Basic Online Course - Command Prompt

Read / Write Windows Command Prompt from VB 2010

Read / Write Windows Command Prompt from Visual Basic 2010

Command Prompt

A command prompt is an entry point for typing computer commands in the Command Prompt window. By typing commands at the command prompt, you can perform tasks on your computer without using the Windows graphical interface.

Command Prompt Commands

(A)
ADDUSERS Add or list users to/from a CSV file
ARP Address Resolution Protocol
~ ASSOC Change file extension associations
ASSOCIAT One step file association
AT Schedule a command to run at a later time
ATTRIB Change file attributes

(B)
BOOTCFG Edit Windows boot settings
BROWSTAT Get domain, browser and PDC info

(C)
CACLS Change file permissions
~ CALL Call one batch program from another
~ CD Change Directory - move to a specific Folder
CHANGE Change Terminal Server Session properties
CHKDSK Check Disk - check and repair disk problems
CHKNTFS Check the NTFS file system
CHOICE Accept keyboard input to a batch file
CIPHER Encrypt or Decrypt files/folders
CleanMgr Automated cleanup of Temp files, recycle bin
CLEARMEM Clear memory leaks
CLIP Copy STDIN to the Windows clipboard.
~ CLS Clear the screen
CLUSTER Windows Clustering
CMD Start a new CMD shell
~ COLOR Change colors of the CMD window
COMP Compare the contents of two files or sets of files
COMPACT Compress files or folders on an NTFS partition
COMPRESS Compress individual files on an NTFS partition
CON2PRT Connect or disconnect a Printer
CONVERT Convert a FAT drive to NTFS.
~ COPY Copy one or more files to another location
CSCcmd Client-side caching (Offline Files)
CSVDE Import or Export Active Directory data

(D)
~ DATE Display or set the date
Dcomcnfg DCOM Configuration Utility
DEFRAG Defragment hard drive
~ DEL Delete one or more files
DELPROF Delete NT user profiles
DELTREE Delete a folder and all subfolders
DevCon Device Manager Command Line Utility
~ DIR Display a list of files and folders
DIRUSE Display disk usage
DISKCOMP Compare the contents of two floppy disks
DISKCOPY Copy the contents of one floppy disk to another
DISKPART Disk Administration
DNSSTAT DNS Statistics
DOSKEY Edit command line, recall commands, and create macros
DSADD Add user (computer, group..) to active directory
DSQUERY List items in active directory
DSMOD Modify user (computer, group..) in active directory

(E)
~ ECHO Display message on screen
~ ENDLOCAL End localisation of environment changes in a batch file
~ ERASE Delete one or more files
~ EXIT Quit the current script/routine and set an errorlevel.
EXPAND Uncompress files
EXTRACT Uncompress CAB files

(F)
FC Compare two files
FIND Search for a text string in a file
FINDSTR Search for strings in files
~ FOR /F Loop command: against a set of files
~ FOR /F Loop command: against the results of another command
~ FOR Loop command: all options Files, Directory, List
FORFILES Batch process multiple files
FORMAT Format a disk
FREEDISK Check free disk space (in bytes)
FSUTIL File and Volume utilities
FTP File Transfer Protocol
~ FTYPE Display or modify file types used in file extension associations

(G)
GLOBAL Display membership of global groups
~ GOTO Direct a batch program to jump to a labelled line

(H)
HELP Online Help 

(I)
~ IF Conditionally perform a command
IFMEMBER Is the current user in an NT Workgroup
IPCONFIG Configure IP

(J)
KILL Remove a program from memory

(L)

LABEL Edit a disk label
LOCAL Display membership of local groups
LOGEVENT Write text to the NT event viewer.
LOGOFF Log a user off
LOGTIME Log the date and time in a file

(M)

MAPISEND Send email from the command line
MBSAcli Baseline Security Analyzer.
MEM Display memory usage
~ MD Create new folders
MKLINK Create a symbolic link (linkd)
MODE Configure a system device
MORE Display output, one screen at a time
MOUNTVOL Manage a volume mount point
~ MOVE Move files from one folder to another
MOVEUSER Move a user from one domain to another
MSG Send a message
MSIEXEC Microsoft Windows Installer
MSINFO Windows NT diagnostics
MSTSC Terminal Server Connection (Remote Desktop Protocol)
MUNGE Find and Replace text within file(s)
MV Copy in-use files

(N)
NET Manage network resources
NETDOM Domain Manager
NETSH Configure network protocols
NETSVC Command-line Service Controller
NBTSTAT Display networking statistics (NetBIOS over TCP/IP)
NETSTAT Display networking statistics (TCP/IP)
NOW Display the current Date and Time
NSLOOKUP Name server lookup
NTBACKUP Backup folders to tape
NTRIGHTS Edit user account rights

(P)
~ PATH Display or set a search path for executable files
PATHPING Trace route plus network latency and packet loss
~ PAUSE Suspend processing of a batch file and display a message
PERMS Show permissions for a user
PERFMON Pe

Example 

1) Copy / Paste filesCopy - This command allows you to copy files from one location to another. To use this command you would type
copy filetocopy copiedfile
For example if you have the file D:\test\test.txt and would like to copy it to c:\windows\test.txt you would type
copy D:\test\test.txt c:\windows\test.txt
and press enter. 
If the copy is successful it will tell you so and give you back the prompt. If you are copying within the same directory you do not have to use the path. 

Here are some examples and what they would do:
copy File.txt ThisFile.bak     Copies the File.txt file to a new file called ThisFile.bak in the same directory
copy File.txt \windows     Copies the File.txt file to the \windows directory.
copy * \windows     Copies all the files in the current directory to the \windows directory.

Redirectors

Re-directors are an important part to using the command prompt as they allow you to manipulate how the output or input of a program is displayed or used. Re-directors are used by appending them to the end of a command followed by what you are redirecting to. For example: Dir > DirOutPuts.txt. There are four re-directors that are used in a command prompt and they are discussed below:

>     This re-director will take the output of a program and store it in a file. If the file exists, it will be overwritten. If it does not exist it will create a new file. For example the command dir > DirOutPuts.txt will take the output of the Dir command and place it in the DirOutPuts.txt file. If dir.txt exists, it will overwrite it, otherwise it will create it.

>>     This re-director will take the output of a program and store it in a file. If the file exists, the data will be appended to the current data in the file rather than overwriting it. If it does not exist it will create a new file. For example the command dir >> dir.txt will take the output of the dir command and appends it to the existing data in the Dir.txt file if the file exists. If dir.txt does not exist, it will create the file first.

<     This re-director will take the input for a program from a specified file. For example the date command expects input from a user. So if we had the command date < date.txt, it would take the input for the date program from the information contained in the date.txt file.

|     This re-director is called a pipe. It will take the output of a program and pipe it into another program. For example Dir | sort would take the output of the dir command and use it as input to the sort command.

How do we use of those info in Visual Basic 2010 ?

There are so many benefits of using Command Prompt Commands in VB 2010, I will give an example of comparing two EXE file (Windows Application) using FC command from VB 2010 which I know is needed most by many developers, there are some tools that actually do that and are based on the usage of FC command.

Example : Compare two applications is called Binary Diff. , FC command operate a comparison process based on the location of the two *.exe files and return the result like this :
xxxxxx: yy zz
The value of xxxxxx specifies the relative hexadecimal address for the pair of bytes, measured from the beginning of the file. Addresses start at 00000000.
The hexadecimal values for yy and zz represent the mismatched bytes from filename1.exe and filename2.exe , respectively.

Syntax :
FC  [drive1:][path1]filename1.exe [drive2:][path2]filename2.exe /B
[drive1:][path1]filename1 : Specifies the location and name of the first file you want to compare. Filename1 is required.
[drive2:][path2]filename2 : Specifies the location and name of the second file you want to compare. Filename2 is required. 
/B  : Compares the files in binary mode. FC compares the two files byte by byte and does not attempt to resynchronize the files after finding a mismatch. This is the default mode for comparing files that have the following file extensions: .exe, .com, .sys, .obj, .lib, or .bin.

To make use of the example :
Create any Visual Basic 2010 Project [Windows Form]
Build it, so you would have an EXE file in Bin\Debug
Copy the exe file to another Dir called C:\Comp, and rename it to (CS.exe)
Edit your Visual Basic 2010 Source Code (Add any line of code)
Build menu : Clear Solution
Build menu : Build solution
now you have another version of the exe file
Rename your recent exe file (Cexe.exe) and paste it in C:\Comp folder with the previous exe file
Now you have 2 different exe (CS.exe and Cexe.exe) files in C:\Comp folder and we want to compare them as Binary Diff.

Create new VB 2010 Project, like this :
VB 2010 Command Prompt
Compare two windows applications in VB 2010 using Command Prompt FC Command
Form
Name : form1
Caption : Compare two exe files
TextBox
'Contains the command Line FC
Name : TextBox1
MultiLine : True
Text :
@Echo Off
FC C:\comp\CS.exe C:\comp\Cexe.exe /B
TextBox
'Will contain the Comparison result of the two EXE application files.
Name
: TextBox2
MultiLine : True
Text :Comparison Result will display here ...
Button
'Executes the Command Line FC in the TextBox1
Name : Button1
Text : Go

Visual Basic Code : Open code area, clear it and paste the following codes ....

Run your application. The result will be like this :
VB 2010 Binary Diff example
Comparison Result of Comparing two windows applications using FC command from VB 2010
You can extend your work further and further ..... If you have any questions please comment. Thank you for reading Visual Basic Online Course - Command Prompt

Here are some online Visual Basic lessons and courses :

Saturday, January 11, 2014

Visual Basic Freelance Requirements Document, Event Planning Document and Use Case Definition

Visual Basic Freelance Job - Understanding a client needs
Visual Basic Freelance Job - Understanding a client needs

Writing Requirements Document

 is a *.Pdf, *.Doc, *.Docs, *.Xml file describes what the your client needs from you "An Application" including but not limited to (Application Title, Purpose, Algorithms procedures and conditions, Notes and restrictions, Comments) these were the most famous requirements and your job as a programmer is to study well these points and design your applications according to it. Another way is to write it for your client if required, sometimes clients need to understand what you've done as a programmer, maybe they will hire some else in the future when you are not available.

This is different from VB .Net Documentations you won't be needing codes or anything, everything depends one the client's request or who ever requests it from you, as a programmer asked to provide this document, honesty is a must, you need to provide the client with everything, starting your logic to deploying methods and you shall accept to do it or not, it is controversial subject.

In the other hand 90% or Requirements Docs are provided by the client or requested by the contractor (Programmer) to ensure that his work (Application) will meet the client's demands to the fullest or at least almost the fullest.

The Requirements Doc. always/must be provided before the application's beginning by the client's to the programmer or along with the application by the programmer to the client.

Writing Event Planning Document 

is the same as the Requirements Doc. format file. It describes what is going on the application's interface UI, specifically describes what happens (The event) when the client's user will click on something on your form or the form_load event itself.
For example, if you have a button in your applicaiotn you will provide its name and the events that are bound to it (Click, DBLClick,. .... etc) and what happens when the client's perform an event of those above, most Planning Events Docs are tables design.

It is provided when requested and as the Requirements Doc. it is a controversial point of view between the prgrammer and the client, you may or you may not provide it if requested.

The VB .Net Event Planning Doc. always/must be provided if agreed by your side as a programmer (contractor), you will describe each and every control's event triggers in your application to the client.

The VB .Net Event Planning Doc. always provided to the client along with application or after, and may be designed and logically configuered by the programmer before writing the codes or designing the UI (User Interface), it should give a full understanding description to the methods used in desgining the User Interface and events related to each control.

Writing Use Case Definition 

is the same as the Requirements Doc. and the Event Planning Doc.'s format file. It describes the logic of/in the application you provide as a programmer to the client if requested. But this time it is a 50\50 chances, means it could be requested by the client or by you and also it should give you as a programmer the mean to reach the client's ideas about the application.

The Use Case Definition if requested by the programmer, means that the programmer is seeking the best image in the client's head and he wants to fully satisfies his client. If requested by the client means that the client already knows what he is seeking he is not just looking for a programmer, no! he is looking for a programmer to do this as he has in mind, maybe he already saw something and wants the exact same thing.

The Use Case Definition is more like terms to the programmer but also relieves him from over coding events that are not really needed ofcourse if asked by the client's side.

All of the 3 Documents ( Use Case Definition, equirements Doc and Event Planning Doc.) depends on the contract between you and the client. I will show you how to do it in a small application project using VB .Net 2010 as if provided\requested by a client soon.4

Here are some online Visual Basic lessons and courses :

Visual Basic Courses - Share