473,473 Members | 2,131 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to save the cam pic file in vb

1 New Member
hai friends i am new to this i working in a proj to save a cam pic for profile maintenance. It work good i can save one one pic if i try to save another pic it overwrite the old one :(.
any one help me to save file name differently each time when button is clicked each time....
here his my code....

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSave_Click()
  2.   Dim bm As Image
  3.     '
  4.     ' Copy image to clipboard
  5.     '
  6.     SendMessage hHwnd, WM_CAP_EDIT_COPY, 0, 0
  7.     ClosePreviewWindow
  8.  
  9.     picCapture.Picture = Clipboard.GetData
  10.  
  11.     CommonDialog1.CancelError = True
  12.     CommonDialog1.FileName = "Webcam1"
  13.     CommonDialog1.Filter = "Bitmap |*.bmp"
  14.  
  15.     On Error GoTo NoSave
  16.  
  17.     SavePicture picCapture.Image, "c:\test12345 .jpg"
  18.  
  19. NoSave:
  20.  
  21.     cmdSave.Enabled = False
  22.     cmdStart.Enabled = True
  23.  
  24. End Sub
Sep 15 '12 #1
2 1953
zmbd
5,501 Recognized Expert Moderator Expert
KABI123,
Welcome to Bytes.
As this is your first post, I've cleaned up your posted code by removing the extra returns and placed the required code tags.
Line 17 is your issue... you've hard-coded the file path and name.

Basic strategy is:

You need to use a counter that will increment.
Use a string variable to build the file and path name to pass to save command.

I'd check for the existence of the file in question too. VB has the DIR function that will allow you to check for the existence of a file or folder etc (http://msdn.microsoft.com/en-us/libr...(v=vs.60).aspx) You can use this function along with the Len to check if the file already exists.

A static global variable would be able to hold the counter value between calls... a dozen other ways to hold this counter.

-z
Sep 15 '12 #2
Killer42
8,435 Recognized Expert Expert
I'd just like to point out that you've set up a few parameters for a common dialogue control (presumably intending to prompt the user for a file name) but then failed to show the dialogue.
Sep 17 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: juli jul | last post by:
Hello,how can I override(save) file in c#? (I am working with XmlDocumnet) Thanks! *** Sent via Developersdex http://www.developersdex.com ***
9
by: Ivan Demkovitch | last post by:
Hi! I would like to know if I can save File on Server using server-side code? For example, I like to create thumbnail images and populate specific directory. Do I need specific permissions...
1
by: Kapil | last post by:
Hi All can u tell me how to save dynamically generated file in asp.net. like save file dialog in asp.net. kapil
6
by: Mike | last post by:
can i open the save file dialog box from a asp.net web page? thx
4
by: Jonny | last post by:
Hello Group How do I open a Save File Dialog from an ASPX page behind a browse button? Any help would be fantastic!! I am using ASP.NET 1.1 using VB.NET as the coding language TIA
3
by: mse07 | last post by:
hi for every one i want to save text file in specified bath without show the save window i write code that save file but that code show save window : CommonDialog1.FileName =...
2
by: AccessHunter | last post by:
Hi, In my VBA code I am saving an excel spreadsheet with data from a table. I would like to prompt the Save File or Save As Dialog box with a default File Name, after opening the spreadsheet. ...
3
by: vedika | last post by:
hi, I created one application in which there is export functionality. I am using sqlCE as database . When user click on "export" a save file dialog appeare and file saved in html format from...
2
by: simonyong | last post by:
Hello, anyone I had search for few days with how to save file when user choose a file name from listbox and i will search the file from database and user can save it into their desktop what I had...
1
by: mihir0288 | last post by:
I want to save HTML file that i open in web browser on my hard disk without using save file dialog box. I want to save it as html page through only code and without user interactions.
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.