|
Hello!
I want to compress a file for transfer and the decompress later..
How can I do it using vb.net. I have .Net Framework 1.1 installed.
I tried System.IO.Compression namespace but it is for Framework 2.0 therefore cant use it.
Any suggestion...material...
Thanx
_mubashir
|
|
|
|
|
You can use a free library for .NET: SharpZipLib
You can download this library from:
SharpZipLib
And you will need the following code to compress a file:
Public Shared Sub ZipFile(ByVal strFileToZip As String, ByVal EntryName As String, ByVal strZippedFile As String, ByVal nCompressionLevel As Integer, ByVal nBlockSize As Integer)
If (Not System.IO.File.Exists(strFileToZip)) Then
Throw New System.IO.FileNotFoundException("The specified file " + strFileToZip + "could not be found. Zipping aborted.")
End If
Dim strmStreamToZip As System.IO.FileStream
strmStreamToZip = New System.IO.FileStream(strFileToZip, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim strmZipFile As System.IO.FileStream
strmZipFile = System.IO.File.Create(strZippedFile)
Dim strmZipStream As ZipOutputStream
strmZipStream = New ZipOutputStream(strmZipFile)
Dim myZipEntry As ZipEntry
myZipEntry = New ZipEntry(EntryName)
strmZipStream.PutNextEntry(myZipEntry)
strmZipStream.SetLevel(nCompressionLevel)
Dim abyBuffer(nBlockSize) As Byte
Dim nSize As System.Int32
nSize = strmStreamToZip.Read(abyBuffer, 0, abyBuffer.Length)
strmZipStream.Write(abyBuffer, 0, nSize)
Try
While (nSize < strmStreamToZip.Length)
Dim nSizeRead As Integer
nSizeRead = strmStreamToZip.Read(abyBuffer, 0, abyBuffer.Length)
strmZipStream.Write(abyBuffer, 0, nSizeRead)
nSize = nSize + nSizeRead
End While
Catch Ex As System.Exception
Throw Ex
End Try
strmZipStream.Finish()
strmZipStream.Close()
strmStreamToZip.Close()
End Sub
A tipical call to this method is:
ZipFile("c:\outputfile.zip", "inputfile.txt", "c:\inputfile.txt", 7, 16348)
Regards,
Vidal Gutierrez.
Vidal Gutiérrez Ch.
|
|
|
|
|
Thanx a lot it works.......
_mubashir
|
|
|
|
|
I have made a program Visual Basic .NET witch uses DirectX 8.1. Now I have rewritten this program for DirectX 9.0c, but one thing is not working anymore, because Microsoft has not included Directshow anymore in DirectX 9.0c.
Now let me explain what the problem is. With my program, I can play movies. I can also capture the movie, but I can't grab a frame anymore. This is the problem I encounter.
I have tried many ways to get Directshow in my Visual Basic .NET. I have downloaded a file, directshowlib.dll, and I tried to install the software Platform SDK from Microsoft. The software Platform SDK will not install at my PC, and with the directshowlib.dll I can't solve the problem.
Can anyone send me some information, about what program I need to install on my PC, and what commando's I need to use to get this software to work?
|
|
|
|
|
Hi,
I am searching in MODI API's to convert raw text to Tiff. But I couldnt find anything to do that. I dont know if i have to use printing interface in VB.net to do the same. Can anyone help me please.
Harish
|
|
|
|
|
Hello Everyone,
I have create activeX control in MFC adding one event to that
control having parameter of type VARIANT. but when we use
that control in VB and run that application, it give error
"variable uses an Automation type not supported in Visual Basic"
how can i solve this problem.
Whats diff. between MFC VARIANT and VB variant datatype.
help me..
Thanks in advance
Regards
Rajesh Kapure
|
|
|
|
|
Hi,
I have a datagrid that is databound. One of the fields is a 'date' field(which comes from database). What I need to do is that if the date is current data , i.e. today's date then I need to display an animated image of 'New' sign next to it and it is anything other than today(which is ofcourse past date ) then I need to display animated 'Old' sign image.
I have the images saved in the same directory as the application. I have also created a template column for the Image and a Itemdatabound sub but I do not know th exact method or syantax to include an image file in the Itemdatabound Event.
Any help anyone please?
thanks a ton!
Aartee.
...HE is watching Us All!
|
|
|
|
|
Eureka!!! I got it...
Aartee.
...HE is watching Us All!
|
|
|
|
|
Hi,
I have two windows forms.User opens the first form(form1) and clicks "open" button then a new form opens(form2).
He makes a choice in form2 .I need to add some string to listBox that is on form1 when user clicks button on the form2. Both forms are open at this time.
If i use
"Dim myForm As New Form1"
it makes the change i need but it creates a new form1.
would someone send some syntax for that?
Thanx in advance..
--junior coder--
|
|
|
|
|
You can pass the form1 as reference to form2 and when the user clicks button on form2 set the string in form1's reference.
That is, When displaying form2 from form1 you would say,
Dim form2 as new form2(form1)
In the Form2's constructor(Public Sub New)
say Public Sum New(byref Form1 as form1)
Hope this helps.
|
|
|
|
|
Here is form1 code:
Public myform2 As New form2
I defined form2 as global variable
Here is form2 code when you hit a button:
Dim f1 As New Form1<br />
f1.Show()<br />
f1 = Me.Owner<br />
<br />
f1.textBox1.Text="something else"
But it does not work
here is error message:
An unhandled exception of type 'System.NullReferenceException' occurred in TestForms.exe
Additional information: Object reference not set to an instance of an object.
--junior coder--
|
|
|
|
|
I assume you have a button in form1 to invoke form2.
So put this code in button_click event of the form1 where you call the form2.
Form1 Code
----------
Dim myform2 As New Form2(Me)
myform2.ShowDialog()
In form2
Declare a Variable
Dim prevform As Form1
If you click on the + sign near the Windows Form Designer generated code,You will see the Public Sub New. it should look like this.
Public Sub New(ByRef form1 As Form1)
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
prevform = form1
'Add any initialization after the InitializeComponent() call
End Sub
In the Form2 button_click (where you want to call form1, paste this code.
prevform.TextBox1.Text = "something else"
Me.Hide()
This should work fine.
|
|
|
|
|
thanx it works fine..
--junior coder--
|
|
|
|
|
I have one datagrid for fetch and display the values from the table.
I need to adding items to datagrid at runtime using vb.net.
I want the code.
my code is
Dim con As SqlClient.SqlConnection
Dim Cmd As SqlClient.SqlCommand
Dim da As SqlDataAdapter
Dim ds As New DataSet
Dim constring As String = "data source=ccs10; initial catalog=gcis;user id=jpa;password=jpa"
Private Sub Btn_Raise_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Raise.Click
Dim CoMm As String
con = New SqlClient.SqlConnection(constring)
cmd=new sqlclient.sqlcommend("Select * from Paperrfq")
da = New SqlClient.SqlDataAdapter(cmd)
da.Fill(ds, "paperrfq")
DataGrid1.DataSource = ds.DefaultViewManager
aruljothi
|
|
|
|
|
Can you please be more specific on the nature of your problem? Please tell more about your data fields that you need to display. I am saying this because I do this all the time and maybe I can help you.
Aartee.
...HE is watching Us All!
-- modified at 3:02 Tuesday 30th August, 2005
|
|
|
|
|
hello mam,
Thanks for ur reply.i am a beginner in dotnet.i wud like to know about the data grid functionality.my requirement is i should be able to view the data in the datagrid from the database as well i want to enter new data in the same data grid to update my database.is this possible in vbdotnet and pls help me in getting things right.
I have more datafields in a table and display that in a datagrid.
Datafields are Empno as integer,empname as string
thank u
aruljothi
|
|
|
|
|
Hi ArulJothi,
---my requirement is i should be able to view the data in the datagrid from the database as well i want to enter new data in the same data grid to update my database.is this possible in vbdotnet ---
Yes it is possible to view the data as well as to update it. There are a couple of ways to do it,
1.In your SQL statement write a select stt to display the fields you need in the datagrid, do the rest of databse-connectivity,bindgrid() etc..coding. In your datagrid include a 'Hyperlink' column for 'change/Update Form' and redirect the link to your actual form by providing a 'URL' in the url field of the Property Builder i.e. Propertybuilder-->columns-->hyperlink column-->
HeaderText:Change/Update-->text:Update-->URLField:[your primary key of the form/table]eg:formNo-->URLFormat string:[your original form name not the datagrid one]eg: formname.aspx?formno={0}
this way your datagrid will bring you straight back to the form, you can make changes and save and the changes will be reflected in the datagrid.
2. Add the 'Edit,Update,Cancel' button and write the sub say, updatetable for update and edittabel for edit on the datagrid code behind page, include OnUpdatecommand="updatetable" and Oneditcommand="edittable" in the HTML page. so this will edit the columns and you can make changes to the fields you included in your datagrid(not form) and update it.
I hope this helps .let me know if you need more clarifications on any of the above.
good luck.
Aartee.
...HE is watching Us All!
|
|
|
|
|
hi,
i think u said for web application, may i get the solution for window application to add/update/delete at runtime
|
|
|
|
|
Hi,
I want to display a message box without showing a OK button. This I need because I have to display a processing message in an application which is in the process of displaying a website in the axBrowser window.
Can anybody reply me....
Thanks in advance..
Regards,
Jaya
|
|
|
|
|
If you want no button at all, then you need to create your own. Also, if you create a modal dialog, as the Message Box is, nothing will happen while it is being shown, unless it's in another thread.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
Can you please tell me whether I can able to disable the OK button of message box while using in Windows application with C# code.
If this is possible I shall be able to close the message box after a while.
Thanks in advance,
Regards,
Jaya
|
|
|
|
|
No, you can't. You will still need to create your own dialog, a trivial task in any case.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi ,
I have a datagrid in which I have a button column 'Delete' that works by calling 'Ondatagrid_deleteCommand'.
My problems is when I try to delete a record by clicking on 'Delete' button in datagrid, I get the following error
"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index "
I am clueless as to why this is happening since the same routine is working in other application which is exactly similar and ofcourse in which I am using a datagrid.
The sub for delete command is as follows:
**************************************************************************************************<br />
Sub DataGrid_DeleteCommand(sender As Object, e As DataGridCommandEventArgs)<br />
'Create the objects for the connection<br />
Dim myConnection As New SqlConnection(ReadDBConnectionString())<br />
Dim DeleteCommand As SqlCommand = new SQLCommand()<br />
Dim Transaction as SQLTransaction<br />
<br />
'Define the Query<br />
<br />
DeleteCommand.CommandText = "DELETE from chequedata where cheqregno= " &DataGrid.DataKeys(e.Item.ItemIndex)<br />
'Add the Parameters to the Query with the actual Value<br />
<br />
DeleteCommand.Connection = myConnection<br />
<br />
<br />
'Start Try Block<br />
Try<br />
'Open Connection<br />
myConnection.Open()<br />
'Begin Transaction<br />
Transaction = myConnection.BeginTransaction()<br />
'Tell Command Object which Transaction to use<br />
DeleteCommand.Transaction = Transaction<br />
'Execute the SQL Command<br />
DeleteCommand.ExecuteNonQuery()<br />
'Nothing happend - Commit Transaction<br />
Transaction.commit()<br />
'Show Message in Label<br />
lblMessage.Text = "Entry deleted"<br />
catch ex as Exception<br />
'Failure occured - Rollback Transaction<br />
Transaction.RollBack()<br />
'Write Message in Label<br />
lblMessage.Text = "Entry Not deleted"<br />
Finally<br />
'Close connection<br />
myConnection.Close()<br />
<br />
DataGrid.EditItemIndex = -1<br />
'Refresh the Grid and show changes<br />
RefreshGrid(Cint(ddlBranch.SelectedITem.Value),txtsearch.text)<br />
<br />
End Try<br />
End Sub<br />
***************************************************************************************************
Thankyou all for all the help. It is much appreciated.
Aartee.
...HE is watching Us All!
|
|
|
|
|
I wanted to make a vb application which would dial a telephone number using
the modem. When the person on the other end lifts up the telephone (answers
the phone), the application should start playing an audio file(eg. .wav
file).
The approach I took was using the Tapi. As my modem is connected to the
serial port on my computer I send AT commands to make the phone call . This
is working fine and the call is being placed.
I wanted to know whether this is possible at all? Whether I am approaching
the wrong way? If it is possible, then please give some suggestions or
samples(vb or vc). If it is not possible , then what is the best way to do
so
|
|
|
|
|
Hi,
After searching the web and finding nothing, I'm trying this forum to find some answers.
1) There is two type of hotfixes for Windows (type 1 and type 2). How can I get this type. Somebody know what I could check to get it.
Something like GetHotfixType(sHotfixPath) and return 1 or 2.
2) I need to get a DLL language but can hardly find informations about a way of doing it.
Sample code in any programming language would be appreciated. I need it for VB but it don't matter, I'm gonna do the conversion.
Thank you for replying. Any information is welcome.
|
|
|
|