How To Save An UTF-8 String As File Name With CreateFileW API Function
I am currently developing a upload component for web page, the html page uses UTF-8 encoding and uploads a file that named with simplified chinese characters. The vb6 component uses the MultiByteToWideChar API function to convert the data requested from Request object with UTF-8 (65001), then uses CreateTextW function to save file onto disk.
Code: lngFileHandle = CreateFile(strFileName, GENERIC_WRITE, 0, ByVal 0&, CREATE_ALWAYS, 0, 0) I've tried to use CreateFileA() function, but strFileName contained unicode chars which CreateFileA() did not recognise (shown as ?) and returned a "Bad file name or number" error. Using CreateFileW(), it accepts the file name, but it does not recognise the encoding of strFileName and saves the file under the folder where the vb project is running, this time the file name is made up of unknown characters. I then use: StrConv(strFileName, vbUnicode) and got some of the simplified chinese characters right, and others became "?" or square blocks. What I don't understand is that the byte array or string which passed into CreateFileW() is already in UTF-8 format, but still requires the StrConv() function to convert it into Unicode format to create a partially correct filename. Does Windows XP/2003 store file names in different format other than UTF-8? Even if I pass a string without any encoding (e.g. "aaa"), CreateFileW() still creates the file with unreadable file name. How can I save the file name in Unicode/UTF-8 format correctly without the need of StrConv()?
Thank you very much!
P.S. Please forgive my bad english.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Save An UTF-8 String As File Name With CreateFileW API Function
I am currently developing a upload component for web page, the html page uses UTF-8 encoding and uploads a file that named with simplified chinese characters. The vb6 component uses the MultiByteToWideChar API function to convert the data requested from Request object with UTF-8 (65001), then uses CreateTextW function to save file onto disk.
Code:lngFileHandle = CreateFile(strFileName, GENERIC_WRITE, 0, ByVal 0&, CREATE_ALWAYS, 0, 0)
I've tried to use CreateFileA() function, but strFileName contained unicode chars which CreateFileA() did not recognise (shown as ?) and returned a "Bad file name or number" error.
Using CreateFileW(), it accepts the file name, but it does not recognise the encoding of strFileName and saves the file under the folder where the vb project is running, this time the file name is made up of unknown characters.
I then use:
StrConv(strFileName, vbUnicode)
and got some of the simplified chinese characters right, and others became "?" or square blocks.
What I don't understand is that the byte array or string which passed into CreateFileW() is already in UTF-8 format, but still requires the StrConv() function to convert it into Unicode format to create a partially correct filename. Does Windows XP/2003 store file names in different format other than UTF-8?
Even if I pass a string without any encoding (e.g. "aaa"), CreateFileW() still creates the file with unreadable file name.
How can I save the file name in Unicode/UTF-8 format correctly without the need of StrConv()?
Thank you very much!
P.S. Please forgive my bad english.
Edited by - binary_100110 on 11/3/2006 3:47:24 AM
Update Save File Function
Hi VB masters,
I have opened text file function.
What and how can I do to update changes of open file ?
Thank you so much.
Read String From File And Save It To Another File With Change
Private Sub Command1_Click()
Dim FileNum As Long
Dim line1, line2, line3, strfind As String
Dim i As Integer
strfind = "pagebreak"
I am trying to read a string and look for the word "pagebreak" and write the string to a new file repacing the pagebreak with vb newline. I need my new text file to have new pages every time I read the pagebreak string. The following code work, but copy the code to a new file without starting a new page.
Thanks
strfind = "pagebreak"
FileNum = FreeFile
Open "c: est.dat" For Input As #FileNum
Do Until EOF(FileNum)
Input #FileNum, line2
line1 = line1 + line2
i = i + 1
line3 = ReplaceFirstInstance(line1, strfind, NewPage)
Loop
End Sub
Function ReplaceFirstInstance(textbody, searchfor, startover)
FoundLoc = InStr(1, textbody, searchfor)
If FoundLoc <> 0 Then
Open "C: est2.txt" For Output As #2
Print #2, textbody & NewPage
Close #2
Else
ReplaceFirstInstance = SourceString
End If
End Function
Save A Txt File From A String Value
I have a string value "strTemp" that has some data in it.
I want to use a commondialog control to save a text file containing the data in my string.
this is what i have and it is not working
With CommonDialog1
.DialogTitle = "Save"
.InitDir = "C:"
.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
.ShowSave
End With
The problem i am sure is that nowhere in this with statement do I tell the common dialog to save my string....
Any help?
How Do Save A String To A .txt File?
Code:
Private Sub Command2_Click()
Dim sReturn As String
Dim yh As String
Dim ru As String
Open "C:Documents and SettingsjustinMy Documentsemailseamils1.txt" For Input As #1
Do Until EOF(1)
Line Input #1, yh
'This was in Text1.text
'Keep","don't,keep,these,commas,but keep this","and not this,one
sReturn = ReplaceUnwantedCommas(yh)
ru = ru + sReturn
Loop
Close
'I need to save ru to C:Documents and SettingsjustinMy Documentsemailseamils1.txt
End Sub
Anyone Have A Function To Load/save A Variable Into A File?
Ive been coding in vb for years.. and i STILL to this day do not get the stupid file system thing... to do something basic like load or save a variable to a file
do you use get? put? input? lof? buffers? loops? output?
ive seen so many ways, they all get mixed together..
anyone have 2 very simple function that will just load a file and save a file to a string?
thanks
Get Text From A .txt File And Save To A String
How can I get all the lines of text from a .txt file and save them to a string variable? Also, If I put this string variable into a different .txt file later on, will the words still be formatted correctly on their proper lines etc.?
Save Text String As Binary File(?)
in text form file might look like this:
Code:
Content-Type: image/jpeg;
name="A8BQOLHLMBDD.JPG"
Content-Transfer-Encoding: base64
filename="A8BQOLHLMBDD.JPG"
/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAsICAoIBwsKCQoNDAsNERwSEQ8PESIZGhQcKSQr
etc on into 'infinity'
but when downloaded it comes out as a picture
is there vb code to interpret all that text that, for example, in this case, will convert it into an image, or whatever file it might happen to be?
String Export To Text File (save As *.html)?
I have a function that produces a string.
How do I create a new text file and place the string into that?
Also, can I save the text file with the *.html extension so that it will open in IE? -the string of course is html code...
This has probably been answered a gazillion times in here, but all I can find are threads where an entire db is exported, but nothing as simple as a string...
I'm newbie + lost
Function Returning A String From A Text File
dear gurus
i want to write a function (in plain VB 6) which would take a filename as input and return me a string which is stored in the text file. The text file contains only one string. Also please tell me how do i use this function in the calling program.
thanks
Edited by - saeedakhtar on 2/10/2008 12:03:17 AM
How To Declare String For Function Written In Txt File
hi all..
i have this function which is written in txt file i.e
Function display(myValue)
msgbox myValue
..
..
..
from the vb form, i will enter a value in a text1 field and send this value as myValue(use script control) to the above function which is written in txt file. I am able to see the "myValue" only if myValue is integer format i.e 1245631..However, if i enter D1245631, it displays nothing..any idea what caused this?
thanks!
Help To Change Function To Return String Instead Of Writing File.
Hello,
I'm trying to convert the following function so that instead of writing data to a file, it returns a string. I tried myself but the closet I could get was to get it to return a string with gibberish.
Here's the code:
PHP Code:
Public Sub DecodeFile(SourceFile As String, DestFile As String)
Dim ByteArray() As Byte
Dim Filenr As Integer
'Make sure the source file exists
If (Not FileExist(SourceFile)) Then
Err.Raise vbObjectError, "clsHuffman.DecodeFile()", "Source file does not exist"
End If
'Read the data from the sourcefile
Filenr = FreeFile
Open SourceFile For Binary As #Filenr
ReDim ByteArray(0 To LOF(Filenr) - 1)
Get #Filenr, , ByteArray()
Close #Filenr
'Uncompress the data
Call DecodeByte(ByteArray(), UBound(ByteArray) + 1)
'If the destination file exist we need to
'destroy it because opening it as binary
'will not clear the old data
If (FileExist(DestFile)) Then Kill DestFile
'Save the destination string
Open DestFile For Binary As #Filenr
Put #Filenr, , ByteArray()
Close #Filenr
End Sub
Thanks to anyone who can help!
-Justin S.
Reading Image Files Into A String Buffer(since API Function Supports Only String Buf)
Hai all,
im back with another problem!
I am using a API function which accepts data only into a string buffer. (InternetReadFile function in WinINet API).
I tried reading a JPG file from the cache and then writing it out again to disk. I didnt get back a JPG image.
So how do we work around the fact that InternetReadFile reads into a string buffer, but I need the data in a Byte() array, so that I can write back the JPG file properly to disk??
converting each character in the string to Bytes returned an error..
Code:
'Buffer is the string and data is the Byte()
For i = 1 To Len(Buffer)
data(i)= CByte(Mid(Buffer, i, 1))
Next
sorry if im missing something!
thanks for ur time..
Pradeep V
Reading Image Files Into A String Buffer(since API Function Supports Only String Buf)
Hai all,
I am using a API function which accepts data only into a string buffer. (InternetReadFile function in WinINet API).
I tried reading a JPG file from the cache and then writing it out again to disk. I didnt get back a JPG image.
So how do we work around the fact that InternetReadFile reads into a string buffer, but I need the data in a Byte() array, so that I can write back the JPG file properly to disk??
converting each character in the string to Bytes returned an error..
Code:
'Buffer is the string and data is the Byte()
For i = 1 To Len(Buffer)
data(i)= CByte(Mid(Buffer, i, 1))
Next
sorry if im missing something!
thanks for ur time..
Pradeep V
Call A Function By String NameOf Function
Hi,
I have a popup menu I load from a config file into a Dictionary...
ie: Return=ClosePopupMenu (Key=Item in Dictionary named PopupMenuItems)
Then load Keys into a Listbox on seperate Form (the Popup Menu)
"Return" is the text I display in the List,
and "ClosePopupMenu" is the Function I want to call.
So, I tried:
Private Sub lstPopup_Click()
Call PopupMenuItems.Item(lstPopup.ListIndex)
End Sub
=compile error: invalid use of property
So, I tried:
Private Sub lstPopup_Click()
Dim myFunction
Set myFunction = PopupMenuItems.Item(lstPopup.ListIndex)
Call myFunction
End Sub
=compile error: expected Sub, Function, or Property
ANYWAY...
I KNOW there is a way to Call a Function from it's name as a string,
I have done it before but forgot how I did it,
Will be expanding the Application and want clean code, not:
Select Case PopupMenuItems.Item(lstPopup.ListIndex)...
Since that way I cannot change the configuration file without changing all references in the Application to suit said file.
AND...
I know someone in VBForums knows what I'm typing about
SO...
Please help?
Close And Save Excel File, Pass Save Instructions
Hello All,
I was wondering if someone could help me with this. I have the following code-
CODEDim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel.Application")
ExcelSheet.Application.Visible = True
ExcelSheet.Workbooks.Open ("Z:BDCMDAILYDAILY PACKET COVER PAGE.XLS")
'Now print
ExcelSheet.Range("A1:Q44").Select
ExcelSheet.ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$44"
ExcelSheet.ActiveWindow.SelectedSheets.PrintOut copies:=1, collate:=True
ExcelSheet.Application.Quit
Set ExcelSheet = Nothing
End Function
Save File Without Show Save Window
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 :
Code:
CommonDialog1.FileName = "invoices.txt"
CommonDialog1.ShowSave
Call FileCopy(App.Path & "invoices.txt", CommonDialog1.FileName)
i want to save file in specified bath without show the save window .
thank you .
Save Function
I have an mp3 player that has been peiced together from several other ones, it works great except for one small thing,
When I package the app using Inno Setup 2 and using all of the runtime and dependancie files that should be needed (according to VB's Dependency Wizard) I run it on a fresh machine (WinXP pro only, fresh install) it won't save playlists. However when I run it on my vb dev machine it saves them fine. This tells me it is missing a dependency or something, but I can't for the life of me figure out what. I can email a zip copy to anyone that wants to take a crack at it. Thanks in advance.
Vba On 'save' Function
hello, i got a frequent task to save the worksheet whenever the value in a cell of that worksheet changes, so instead of using mouse clicking the 'save' button, can someone help me so vba does it too to save my time?
thanks a lot
PLEASE HELP ME - Save As Function
Please help me i have tried to find the aswer for thins but can not, it does not help much when i am new using assess or do not have the manual.
What i would like to do is everytime i open up a perticular MS WORD templete i would like to automatically save it as a new file name. The file name would come from the data in a text box in the templete. the data in the text box would change each time as it is being imported from MS ACCESS ( I know how to import the data, but i do not know how to refer to the data in the text box in the saveas command)
Please help as i need this for my university work placement that I am currently doing.
Cheers
Chris
Save Function
I can't get the following function to work. There are no bugs so I think I'm missing some thing. It just doesn't save.
Sub Button42_Click()
'
' Button2_Click Macro
'
Dim strFilt As String, strFileName As String, strSaveAs As String
strFilt = "Microsoft Excel File (*.xls),*.xls"
strFileName = Range("c2") & Space(1) & "OP NV EOC.XLS"
strSaveAs = Application.GetSaveAsFilename(strFileName, strFilt)
End Sub
Thanks
Can You Help Me With Save Function
I made a program that saves the score,
but it doesn't work.
The code looks like this
Code:
private sub SaveScore()
Dim FileName as string
Dim 1 As Integer
Dim Score as integer
Score = 10
FileName = App.Path & "
ecord.scr"
Open FileName For Append As #1
Print #1, Score
Close #1
End sub
When I run my program I get the message:
"Bad file name or number"
What do I do wrong???
Save Function
Ok i know how to save a text file, but it prompts user to save it. (to name it)
Is there any way to just save a text file automatically without asking the user?
Help With Save As Function....please!!
I have an excel with multiple worksheets, on each sheet I want to place a button that, when pressed, saves that sheet to a new file. Anyone know how to do this, using saveas, so that the user can input where the file is saved and what the name is.
Thanks!
Save Function . . .
i'm in the process of making a simple game, that i'd like to add a save function to. so far, the only thing i know about that is to add the Common Dialog component and use the code
CommonDialog1.ShowSave
how do you get it to actually save, and what would i want to save the file as?
Save Function
have 2 class modules.
A) Company Module: Stores details of a company.
VB Code:
Option Explicit Dim intID As IntegerDim strName As StringDim strURL As String Dim blnIsNew As BooleanDim blnIsDirty As Boolean Friend Property Let CompanyID(ByVal Value As Integer) intID = ValueEnd Property Public Property Get CompanyID() As Integer CompanyID = intIDEnd Property Public Property Let CompanyName(ByVal Value As String) strName = Value IsDirty = TrueEnd Property Public Property Get CompanyName() As String CompanyName = strNameEnd Property Public Property Let CompanyURL(ByVal Value As String) strURL = Value IsDirty = TrueEnd Property Public Property Get CompanyURL() As String CompanyURL = strURLEnd Property Friend Property Let IsNew(ByVal Value As Boolean) blnIsNew = FalseEnd Property Public Property Get IsNew() As Boolean IsNew = blnIsNewEnd Property Friend Property Let IsDirty(ByVal Value As Boolean) blnIsDirty = ValueEnd Property Public Property Get IsDirty() As Boolean IsDirty = blnIsDirtyEnd Property Private Sub Class_Initialize() Call ClearEnd Sub Private Function Clear() intID = 0 strName = vbNullString strURL = vbNullString blnIsNew = True blnIsDirty = TrueEnd Function
and
B) A Companies Collection: A collection of the above module
VB Code:
Option Explicit Dim colCompanies As Collection Public Property Get Company(ByVal ID As Variant) As Company Set Item = colCompanies.Item(ID)End Property Public Property Get Count() As Integer Count = colCompanies.CountEnd Property Public Function Load(Optional ByVal strSQLWhere As String)Dim oNewCompany As CompanyDim adoRecordset As RecordsetDim strSQL As String Set colCompanies = Nothing Set colCompanies = New Collection strSQL = "SELECT * FROM COMPANIES " & strSQLWhere Set adoRecordset = New Recordset adoRecordset.Open strSQL, madoConnection, adOpenForwardOnly, adLockReadOnly With adoRecordset Do While Not .EOF Set oNewCompany = New Company oNewCompany.ID = .Fields("Company_ID").Value oNewCompany.Name = .Fields("Name").Value oNewCompany.URL = IIf(IsNull(.Fields("URL").Value), "", .Fields("URL").Value) colCompanies.Add oNewCompany Set oNewCompany = Nothing .MoveNext Loop End With adoRecordset.Close Set adoRecordset = NothingEnd Function Public Function Add(ByVal objNewCompany As Company, ByVal strKey As String) As CompanyDim intID As Integer If Len(strKey) = 0 Then colCompanies.Add objNewCompany Else colCompanies.Add objNewCompany, strKey End If Set Add = objNewCompany Set objCompany = NothingEnd Function Private Sub Class_Initialize() Set colCompanies = New Collection lngSelectedItem = 0End Sub Private Sub Class_Terminate() Set colCompanies = NothingEnd Sub Public Property Get NewEnum() As IUnknown Set NewEnum = colCompanies.[_NewEnum]End Property
Obviously I require a Save function. What I need to know is do I place this is the collection or in the single company module?
It is really confusing me...which isn't hard at the moment. I can't find any examples of where or how to implement this
VBA Save As Function
Is there any way that I can create a button in a UserForm that when clicked, the Save As dialog box comes up? If so, how?
Thank You
VBA Save As Function
Just got home David, try this under the button_click() event :
Code:
With CommonDialog1
.ShowSave
.Filter = "*.xls"
.DialogTitle = "save as example"
End With
getfiletosave = CommonDialog1.FileName
Excel.Workbooks(0).Item.SaveAs getfiletosave
hope this helps.
Alex
Save As Function In VBA
I have a form in excel. I have created a button that will save the file. What is supposed to happen is that the form is supposed to be saved as the "control number" which is in cell A3. How can I save a file that will reference a cell for the file name???
Save As Function In VBA
I have a form in excel. I have created a button that will save the file. What is supposed to happen is that the form is supposed to be saved as the "control number" which is in cell A3. How can I save a file that will reference a cell for the file name???
Before Save Function In Excel
Hi Guyz,
I have an vb6 application that is opens an excel file..And this excel file contains macro (before save) .. So when then excel file is opened by vb6 application, and when the user clicks the save button in excel, the beforesave function executes
<code>
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
End Sub
</code>
The problem is that for some reason i want to have this code in the vb6 application, rather than in the excel file..
Because i only want the before save function to be executed if the user opens the excel file using the vb6 application
So any idea how can i achieve this..Any idea??
Thanks In advance
How To Create Save Function
hi everyone..i'm newbie in vb 6 and i really need helps from u guys here.
Actually, i've 9 textboxes and 10 comboboxes in the form. what i want is when i enter Print button, the data will stored in database and in the same time it will go to new form. The link to new form is already successful. the problem now is how to create the save function??
here i paste my code.
Code:
Private Sub SaveData()
'conn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;password ='999999';Data Source=(local);Initial Catalog =TGB"
Conn2.Open
cmd = "INSERT INTO DMF_ERP_TumTag(FactoryID, TTLineNo, DateTime, " _
& "BlockNo, GloveType, TTSize, Side, Color, Texture, Length, Thickness, " _
& "GloveWeight, BasWeight, BasBarCode, CompTankNo, BasketNo, TumblerNo, " _
& "TumblerBoyID, Supervisor)" _
& " VALUES ('" & cboFacId.Text & ", " & ComboBox1.Text & "," _
& " #" & txtDateTime.Text & "#, " & Text2.Text & ", " & cboGloveType & ", " & cboSize.Text & "," _
& " " & cboSide.Text & ", " & cboColour.Text & ", " & cboTexture.Text & ", " & cboLength & "," _
& " " & cboThickness.Text & ", " & Text3.Text & ", " & Text1.Text & ", " & txtBarcode.Text & "," _
& " " & Text4.Text & ", " & Text5.Text & ", " & Text6.Text & " , " & Text7.Text & ", " & Text8.Text & " ')"
rs.Open cmd, adOpenStatic, adLockReadOnly
Conn2.Execute cmd
Save Page As Function
I'm making a webbrowser for a school project (this is my first vb project...) and I wan't to know if it's possible to create a "save page as" button that saves not just the HTML but every other files (images and those stuff) to (just like Firefox does).
For now I'm only able to save de code into a *.txt file or a *.html file using this code:
VB Code:
Private Sub bt_save_page_Click() Dim strwp strwp = pag.LocationName i = 0 Do i = i + 1 'this are all the ilegal caracters If Mid(strwp, i, 1) = "." Or Mid(strwp, i, 1) = "" Or Mid(strwp, i, 1) = "/" Or Mid(strwp, i, 1) = ":" Or Mid(strwp, i, 1) = "*" Or Mid(strwp, i, 1) = "?" Or Mid(strwp, i, 1) = "<" Or Mid(strwp, i, 1) = ">" Or Mid(strwp, i, 1) = "|" Then If Mid(strwp, 1, i - 1) = "" Then strwp = "page1" Else strwp = Mid(strwp, 1, i - 1) End If End If Loop Until i = Len(pag.LocationName) Or strwp <> pag.LocationName '------This is to determine the file's name because there are ilegal caracters strwp = "c:" & strwp & ".html" Open strwp For Output As #3 Print #3, pag.Document.Body.InnerHTML 'page source code Close #3 MsgBox "Page sucessefuly saved but without any images.", vbOKOnly, "Sucess!" End Sub
I've been searching here in the forums for the past 2 weeks (but not only because of this problem..) and I haven't found anything about this. I'm not that good in English so I don't know exactly what I'm suposed to search for.
Need Help On Load/save Function..
I need help on this to make load / save function work..
PS: you can download the exampple and work on that,much easier... But please help!!
What i need here is for the save function to save each item from the list in a new line in the "data.ads" , and for the load function
to clear the list and read each line ,correctly into the list again...
Can anyone help me??
Im stuck, cause i don't know enough...
VB Code:
Private Sub Command3_Click()List1.ClearEnd Sub Private Sub Command4_Click() Dim ls ls = List1.ListCount - 1 List1.ListIndex = 0 'MsgBox ls Open App.Path & "Data.ads" For Random As #1 List1.ListIndex = ls For e = 0 To ls Put #1, , SplitTab(0) & vbTab & "€€" & vbTab & SplitTab(1) Next e Close #1End Sub Function SplitTab(nr)'If List1.ListIndex = -1 Then List1.ListIndex = 0Dim Tabs() As StringTabs = Split(List1.Text, vbTab)SplitTab = Tabs(nr)End Function Private Sub Form_Load()Dim i 'count valueList1.ClearFor i = 0 To 20List1.AddItem "ehh: " & i & vbTab & "Item: " & iNext iEnd Sub Private Sub Command1_Click()'sort/search buttonDim fnd As IntegerDim strTemp, strTemp2List1.ListIndex = 0For fnd = 0 To List1.ListCount - 1''MsgBox fnd 'Need To AutoSelect Item In List Here'Start at first item and ending on last itemList1.ListIndex = fnd 'this gives a "invalid property value" Dim SplitTab() As StringSplitTab = Split(List1.Text, vbTab)strTemp = SplitTab(0)strTemp2 = SplitTab(1)''MsgBox strTemp 'Show you what it does 'strTemp = List1.List(fnd)If InStr(1, strTemp, Text1.Text) Then List1.RemoveItem fndList1.AddItem strTemp & vbTab & strTemp2, 0End IfNext fndList1.ListIndex = 0List1.ListIndex = -1 End Sub Private Sub Text1_Change()Text1.Text = ""End Sub
Webbrowser Save Function (please Help)
K well im bak again.
Im trying to get the sourcecode to a webpage in the same way that internet explorer does it.
When saving using the "save as" command on iexplorer the contents that are saved, are saved in a folder and sometimes include certain scripts and other files.
If anyone knows how to use this same command in vb i would be very very greatful. thank you anyone that replies.
*Andrew*
p.s. id probebly be using a webbrowser so when getting the html i will be getting it from WebBrowser1.LocationURL etc.
IM sure you know more than me. thnx again .
Edited by - Andy Fletcher on 5/3/2002 12:52:32 PM
Using Save-to-disk Function In EVB?
i got some data from comm port and need to show them in a window of the interface (on iPAQ) and save them to a file on the disk. what should i do?
cheers
Trying To Save ' In A String
Im using sql statements and one of my variables has a ' in it.. so it errors out when tyring to execute the update string...
strSQL = "UPDATE List SET Name='" & customer & "'"
that works fine if customer = "Regular Name"
but if customer="Name with 's in it" then it errors on the '
is there a way around it so that it still stores the ' in the data base?
PowerPoint Macro Save Function?
I just have a question, ive been playing with the powerpoint macro function in my VB app, and i can't seem to find how to do the following functions:
1. Save the automated slide to the harddisk (e.g. file.ppt)
2. Open multiple powerpoints and take the data out of them, and strinigng them together in one file.
for ppt macro thing.. i'm using the one at:
http://support.microsoft.com/default...NoWebContent=1
VBA Function To Capture Last Save Date
I'm trying to code a few lines that capture the file's last save date and stores it in a worksheet cell. I'm storing the code as a workbook open event, however, it fails to compile. Please advise. I have included the code below. Thanks!
Private Sub Workbook_Open()
Range("'Summary_Report'!A32").Value = FileDateTime("Projects")
End Sub
Video Capture Save Function
I am using a program that someone created that allows me to view my webcam. It works great and ive modified it to what i need. But it did not come with a function that would allow me to save "Captures" to the local hard disk, or anywhere for that matter. My end all "want" is to send the file to an FTP server, where i can call it. But for now if i can get a simple function that saves it off to the hard drive, i'll fight with transferring the file to the FTP site later. The project i have been using has a module that holds a few Functions, i am assuming this is probably where i will put the function to save off the file. Here is the code for that file.
Code:
Option Strict Off
Option Explicit On
Module Module1
Public Const ws_child As Integer = &H40000000
Public Const ws_visible As Integer = &H10000000
Public Const WM_USER As Short = 1024
Public Const wm_cap_driver_connect As Integer = WM_USER + 10
Public Const wm_cap_set_preview As Integer = WM_USER + 50
Public Const WM_CAP_SET_PREVIEWRATE As Integer = WM_USER + 52
Public Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_USER + 11
Public Const WM_CAP_DLG_VIDEOFORMAT As Integer = WM_USER + 41
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA"(ByVal a As String, ByVal b As Integer, ByVal c As Short, ByVal d As Short, ByVal e As Short, ByVal f As Short, ByVal g As Integer, ByVal h As Short) As Integer
End Module
I went through the Windows SDK Multimedia stuff on MSDN, but the description for each Function is kind of vague. Can someone recommend a function and an example syntaxt that will help me with this problem.
Thank You
Calling A Function To Save To A Table
i have performed validation and populated a datagrid via a command button and using a "pseudo" (temporary) table called OrderDetails2. Now I wish to save the details to the proper table (ie OrderDetails), as every row in the datagrid as to be looped through to achieve this, I am using this code:
Dim iRowCount As Integer
'Dim row As Integer
iRowCount = Adodc3.Recordset.RecordCount
For DataGrid2.row = 0 To iRowCount
Call Save
Next row
the code in the save function is:
Dim iOrderNumber As Integer
iOrderNumber = RS.Columns("OrderNo")
Dim strProductCode As String
strProductCode = RS.Columns("ProductCode")
Dim strProductDesc As String
strProductDesc = RS.Columns("ProductDesc")
Dim iProductQty As Integer
iProductQty = RS.Columns("Quantity")
Dim iOrderPrice As Integer
iOrderPrice = RS.Columns("Price")
Dim nSQL As String
'inserting the order into order detail
nSQL = "Insert Into OrderDetail (OrderNo, ProductCode,ProductDesc, Quantity, Price) " & _
" Values (" & iOrderNo & ", '" & strCode & "', '" & strDesc & "', " & iQuantity & ", " & iFullPrice & ")"
Set RS = Conn.Execute(nSQL)
however, when run, a compile error is thrown "variable required - can't assign to this expression" (referring to the datagrid.row)
what can i do to fix this or is there any different way to can achieve the same functionality? Thanking you!
Calling A Function To Save To A Table
i have performed validation and populated a datagrid via a command button and using a "pseudo" (temporary) table called OrderDetails2. Now I wish to save the details to the proper table (ie OrderDetails), as every row in the datagrid as to be looped through to achieve this, I am using this code:
Dim iRowCount As Integer
'Dim row As Integer
iRowCount = Adodc3.Recordset.RecordCount
For DataGrid2.row = 0 To iRowCount
Call Save
Next row
the code in the save function is:
Dim iOrderNumber As Integer
iOrderNumber = RS.Columns("OrderNo")
Dim strProductCode As String
strProductCode = RS.Columns("ProductCode")
Dim strProductDesc As String
strProductDesc = RS.Columns("ProductDesc")
Dim iProductQty As Integer
iProductQty = RS.Columns("Quantity")
Dim iOrderPrice As Integer
iOrderPrice = RS.Columns("Price")
Dim nSQL As String
'inserting the order into order detail
nSQL = "Insert Into OrderDetail (OrderNo, ProductCode,ProductDesc, Quantity, Price) " & _
" Values (" & iOrderNo & ", '" & strCode & "', '" & strDesc & "', " & iQuantity & ", " & iFullPrice & ")"
Set RS = Conn.Execute(nSQL)
however, when run, a compile error is thrown "variable required - can't assign to this expression" (referring to the datagrid.row)
what can i do to fix this or is there any different way to can achieve the same functionality? Thanking you!
|