|
Ok lets assume that i am getting five printers as follows
1. ABC
2. XYZ
3. TestPrinter1
4. TestPrinter2
5. TestPrinter3
In the above list some of them are network printers and how do i find newtwork printers programatically in VBA?
modified 27-Dec-12 7:46am.
|
|
|
|
|
|
Thank you for msdn cake !!. I will check that and let you know how it tastes.
|
|
|
|
|
Hello and Merry Christmas,
My name is Kismet and I am very new to programming in general. Specifically, I've chosen to study the VB language (at least start from there) and have been successful in developing a small application for use in my office to store customer payment card information.
I'm using MySQL as the RDMS back-end and all is working great. Now, I would like to add functionality that will provide the ability to send automatic or manual email notifications to a card owner when their payment card is about to expire. I've already created a query that pulls records from the DB that are about to expire in 7, 15, 30, and 45 days.
So, I was wondering if there's anybody out that that's willing to help develop this functionality. Simply put, I don't know how to do it and I know there're those of you out there that do and may be willing to work on this pro-bono. I am willing to share the entire solution along with a sample DB.
Please let me know, thanks.
|
|
|
|
|
Take a look at the MailMessage [^] and SmtpClient [^] classes.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Thanks Richard. I will read through and study these two classes. I still don't know how I'm going to use them in my application, but I'm sure somebody out there has a video tutorial I can watch. Thanks.
|
|
|
|
|
If you Google for "email vb.net" or similar you will find lots of hits, including these CodeProject articles[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi, im not a programmer, but trying to get the below to work, my text file in C drive it needs to be read one line at a time and each line sent to the php input
The php script on the test server works fine
http://home.exetel.com.au/upload/dataupload.php?action=get&pcinfo=pcinfo&exceldata1=exceldata1&exceldata2=exceldata2&exceldata3=exceldata3[^]
and the results page for excel is set
http://home.exetel.com.au/upload/dataupload.html[^]
This is the vbscript, but its for full file upload, i need it to read my text file in C:\Temp3\Test.txt, and each line to be passed on its own argument and then to be uploaded.
Code
'fupload.vbs %homedrive%\Temp3\Test.txt http://home.exetel.com.au/upload/dataupload.php pcinfo
' need extra arguments for to pass on exceldata1 exceldata2 exceldata3 etc
'
'Upload file using http protocol And multipart/form-data
'v1.01
'2001 Antonin Foller, PSTRUH Software
do_vbsUpload
Sub do_vbsUpload()
'We need at least two arguments (File + URL)
If WScript.Arguments.Count < 2 Then InfoEcho
'Are some required objects missing?
If InStr(CheckRequirements, "Error") > 0 Then InfoEcho
Dim FileName, DestURL, FieldName
FieldName = "FileField" 'Default field name
Dim aCounter, Arg
aCounter = 1 'Argument counter
For Each Arg In WScript.Arguments
Select Case aCounter
Case 1: FileName = Arg
Case 2: DestURL = Arg
Case 3: FieldName = Arg
End Select
aCounter = aCounter + 1
Next
UploadFile DestURL, FileName, FieldName
End Sub
'******************* upload - begin
'Upload file using input type=file
Sub UploadFile(DestURL, FileName, FieldName)
'Boundary of fields.
'Be sure this string is Not In the source file
Const Boundary = "---------------------------0123456789012"
Dim FileContents, FormData
'Get source file As a binary data.
FileContents = GetFile(FileName)
'Build multipart/form-data document
FormData = BuildFormData(FileContents, Boundary, FileName, FieldName)
'Post the data To the destination URL
IEPostBinaryRequest DestURL, FormData, Boundary
End Sub
'Build multipart/form-data document with file contents And header info
Function BuildFormData(FileContents, Boundary, FileName, FieldName)
Dim FormData, Pre, Po
Const ContentType = "application/upload"
'The two parts around file contents In the multipart-form data.
Pre = "--" + Boundary + vbCrLf + mpFields(FieldName, FileName, ContentType)
Po = vbCrLf + "--" + Boundary + "--" + vbCrLf
'Build form data using recordset binary field
Const adLongVarBinary = 205
Dim RS: Set RS = CreateObject("ADODB.Recordset")
RS.Fields.Append "b", adLongVarBinary, Len(Pre) + LenB(FileContents) + Len(Po)
RS.Open
RS.AddNew
Dim LenData
'Convert Pre string value To a binary data
LenData = Len(Pre)
RS("b").AppendChunk (StringToMB(Pre) & ChrB(0))
Pre = RS("b").GetChunk(LenData)
RS("b") = ""
'Convert Po string value To a binary data
LenData = Len(Po)
RS("b").AppendChunk (StringToMB(Po) & ChrB(0))
Po = RS("b").GetChunk(LenData)
RS("b") = ""
'Join Pre + FileContents + Po binary data
RS("b").AppendChunk (Pre)
RS("b").AppendChunk (FileContents)
RS("b").AppendChunk (Po)
RS.Update
FormData = RS("b")
RS.Close
BuildFormData = FormData
End Function
'sends multipart/form-data To the URL using IE
Function IEPostBinaryRequest(URL, FormData, Boundary)
'Create InternetExplorer
Dim IE: Set IE = CreateObject("InternetExplorer.Application")
'You can uncoment Next line To see form results
'IE.Visible = True
'Send the form data To URL As POST multipart/form-data request
IE.Navigate URL, , , FormData, _
"Content-Type: multipart/form-data; boundary=" + Boundary + vbCrLf
Do While IE.Busy
Wait 1, "Upload To " & URL
Loop
'Get a result of the script which has received upload
On Error Resume Next
IEPostBinaryRequest = IE.Document.body.innerHTML
IE.Quit
End Function
'Infrormations In form field header.
Function mpFields(FieldName, FileName, ContentType)
Dim MPTemplate 'template For multipart header
MPTemplate = "Content-Disposition: form-data; name=""{field}"";" + _
" filename=""{file}""" + vbCrLf + _
"Content-Type: {ct}" + vbCrLf + vbCrLf
Dim Out
Out = Replace(MPTemplate, "{field}", FieldName)
Out = Replace(Out, "{file}", FileName)
mpFields = Replace(Out, "{ct}", ContentType)
End Function
Sub Wait(Seconds, Message)
On Error Resume Next
CreateObject("wscript.shell").Popup Message, Seconds, "", 64
End Sub
'Returns file contents As a binary data
Function GetFile(FileName)
Dim Stream: Set Stream = CreateObject("ADODB.Stream")
Stream.Type = 1 'Binary
Stream.Open
Stream.LoadFromFile FileName
GetFile = Stream.Read
Stream.Close
End Function
'Converts OLE string To multibyte string
Function StringToMB(S)
Dim I, B
For I = 1 To Len(S)
B = B & ChrB(Asc(Mid(S, I, 1)))
Next
StringToMB = B
End Function
'******************* upload - end
'******************* Support
'Basic script info
Sub InfoEcho()
Dim Msg
Msg = Msg + "Upload file using http And multipart/form-data" & vbCrLf
Msg = Msg + "Copyright (C) 2001 Antonin Foller, PSTRUH Software" & vbCrLf
Msg = Msg + "use" & vbCrLf
Msg = Msg + "[cscript|wscript] fupload.vbs file url [fieldname]" & vbCrLf
Msg = Msg + " file ... Local file To upload" & vbCrLf
Msg = Msg + " url ... URL which can accept uploaded data" & vbCrLf
Msg = Msg + " fieldname ... Name of the source form field." & vbCrLf
Msg = Msg + vbCrLf + CheckRequirements
WScript.Echo Msg
WScript.Quit
End Sub
'Checks If all of required objects are installed
Function CheckRequirements()
Dim Msg
Msg = "This script requires some objects installed To run properly." & vbCrLf
Msg = Msg & CheckOneObject("ADODB.Recordset")
Msg = Msg & CheckOneObject("ADODB.Stream")
Msg = Msg & CheckOneObject("InternetExplorer.Application")
CheckRequirements = Msg
' MsgBox Msg
End Function
'Checks If the one object is installed.
Function CheckOneObject(oClass)
Dim Msg
On Error Resume Next
CreateObject oClass
If Err = 0 Then Msg = "OK" Else Msg = "Error:" & Err.Description
CheckOneObject = oClass & " - " & Msg & vbCrLf
End Function
'******************* Support - end
Really hope some one is able to help, i just cant get my head around this to figure it out. Im so lost in the code
Hope this is ok to post here i searched and found nothing for vbscript at google
vbscript site:http://www.codeproject.com/Forums/
Once things are set i do have a htaccess file to try and restrict people to it by IP, i hope that should make it safe and ok
|
|
|
|
|
Hi friends,
I am a C Developer. Now i assigned to a new project which has front end as vb, Application layer is C++ and back end is sql server. since i am new to these platforms i am trying to implement the application using this.
i tried one small application using our company's already written api. for example, i had created a front end with two text boxes, and when i try to save the record, its showing run time error like, "method 'insert' of object 'datasource' failed". i just want to know the reason why these error showing? and how to rectify it?
|
|
|
|
|
Welcome to the VB.NET forum. I suggest you post your question in a more relevant forum, including a code-snippet of the code that throws the error.
|
|
|
|
|
Dear(s)
I somehow stuck. Pleaes help me in this regard.
I am trying to incorporte Arabic language support in my application. I have done the following.
1. Took Textbox with Arial Unicode MS Font and Arabic charset.
2. At backend I change my field to NVARCHAR to hold unicode.
Alls went well execpt, When i took input in arabic from user, the textbox gives me this ÚÇãÑ ÑÔíÏ after taking input. I ll try to convert it into string but fail.
And in SQL Server the Insert statement saves the same it get from textbox not the arabic text.
Please help me in this regard
Ahsan Sheraz
|
|
|
|
|
The VB.NET IDE is available for free, as is the runtime. I strongly suggest you switch your platform. VB6 is no longer actively supported.
To make the decision easier; this is a problem with text-encodings. VB.NET would convert it to UTF and be done with it - no more "weird characters".
|
|
|
|
|
Dear Brother
Thanks very much for your reply, but I am working on an ERP having 7 fully functional modules, I cannot switch over right now the platform. Please help me.
Let me tell you this junk is displaying correct value in text box or crystal repots having font supports arabic charset. But at the time of saving in (Insert statement) textbox.text gives me this junk, How can I play with them.
Thanks in advance
ahsan sheraz
|
|
|
|
|
There's nothing to play with. First, VB6 was know to have bad support for Right-to-Left text.
But, the textbox will display any text it's given, provided the font being used supports the appropriate characters. It'll look like junk if the font doesn't support it. So, where exactly are you seeing this "junk"?
|
|
|
|
|
Member 9707221 wrote: Dear Brother
I'm neither.
Member 9707221 wrote: Let me tell you this junk is displaying correct value in text box or crystal repots having font supports arabic charset. But at the time of saving in (Insert statement) textbox.text gives me this junk, How can I play with them.
Like I said, it's a dead language. If you want to use it, you'll be doing a lot of archeology.
http://blogs.msdn.com/b/vsarabic/archive/2012/04/05/install-arabic-vb6-applications.aspx[^].
|
|
|
|
|
i want to use class Win32_DefragAnalysis(WMI) to scan status of other volume, but it is not active, exactly, the For-each is not work, please help me,
<pre lang="vb">Private Sub defrag_analysis()
On Error Resume Next
Dim item
Dim nameSQL
Dim wmiOBJECT
Dim itemCOLLECTION
Set wmiOBJECT = GetObject("Winmgmts:\\.\root\cimv2")
nameSQL = "select * from Win32_DefragAnalysis" ' Where VolumeSize > 0 "
Set itemCOLLECTION = wmiOBJECT.ExecQuery(nameSQL)
For Each item In itemCOLLECTION
'not print properties of item
MsgBox "VolumeSize : " & item.VolumeSize
MsgBox "Name : " & item.VolumeName
MsgBox "FreeSpace :" & item.FreeSpace
MsgBox "AverageFileSize : " & item.AverageFileSize
Next
MsgBox "jump here"
End Sub
</pre>
|
|
|
|
|
Since when does VB6 have a "for-each"? Did I mention it's a dead language? Why are you still using it?
The VB.NET IDE is available for free, as is the runtime. I strongly suggest you switch your platform.
|
|
|
|
|
Hi, I need some help on printing data on a listview having 20 columns of data, how do i do that
|
|
|
|
|
|
code for puzzle game having 9 comand buttons using if statement
|
|
|
|
|
No one is going to just give you code. You must present what you have done so far and describe where you need assistance, then they might show you a way to solve your problem.
Good luck.
|
|
|
|
|
|
Does anyone have a code for VB program to set the time example 30 minutes could turn off the Internet (ADSL), much like internet cafes?
|
|
|
|
|
And you expect someone to just hand over their hard work for you to turn in as your own??
|
|
|
|
|
|