|
I have setup a datagrid and successfully filled it with data and always the top left cell is highlighted when it opens. How do I access the value in this cell without clicking on the cell itself? The cell value must be somewhere as it is highlighted when the grid opens.
Any help would be appreciated.If I click on the highlighted cell I can get the value it contains but that's not what I want at datagrid startup.At startup the grid opens in one tab and what I want is to click a different tab and for the value to be used to populate a set of textboxes on the new tab but only when the datagrid is first activated. After that it is no problem as a new set of textbox data is obtained by clicking a datagrid cell entry. I looked on msdn and it talked about a datagrid selection start value but it doesn't exist.
jenkinsdjj
jenkinsdjj
|
|
|
|
|
Either use the source location of the data, or get it from the datagrid via its cell row and column.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Thanks for that. I realised afterwards that I should access the data source feeding the datagrid. All is well now. Thanks again
jenkinsdjj
jenkinsdjj
|
|
|
|
|
Greetings!
I am currently working in an automation to extract data from IE. I have a scenario where two page will be accessed, the first one is the page without username and password on it and the second one is the page with login page to log username and password...
I am currently working on a code where the condition is if the account is logged is as "none" and level as "Administrator", then the page will be accessed and will be directed to the specific url. but when the account is logged in as "none" and level as "Guest", then will be directed to the login page and username and password will be entered.. the problem is the value or the innertext I am extracting has a <br /> between words, how can I set the condition like this?
[HTML]<div id="userid">Account: none <br /> Level: ADMINISTRATOR</div>[/HTML]
[HTML]<div id="userid">Account: none <br /> Level: GUEST</div>[/HTML]
[CODE]If .Document.GetElementById("userid").innertext = "Account: none " & "<br />" & "Level: ADMINISTRATOR" Then
.Navigate linktesturl
Do While .Busy: DoEvents: Loop
Do While .ReadyState < 4: DoEvents: Loop
.Visible = True[/CODE]
....code continues....
I appreciate your feedback. Thank you. :)
|
|
|
|
|
You normally would not use the contents of a web page like this. You normally get the state from some state object, not the contents of the HTML.
|
|
|
|
|
well, due to limited references, this line is the one I use to identify the differences of the page status, (one with no login, and the other one with login).. Anyways, do you have an idea there which should I use in this case instead?... appreaciate your feedback.
|
|
|
|
|
I have no idea since I don't know anything about your application, what type it is (Windows Forms, WPF, ASP.NET, ...), how it's organized, what it's supposed to be doing, ...
|
|
|
|
|
I have an application which is near complete, but I never thought it would get this big or desired. The application reads a folder with files in it for user settings, then waits for user input. When input is started, it does specific searches online. When it is doing these searches, the application appears frozen until it finds what the user was looking for and prompts the user for input.
I have tried a few ways to get threading into this, but everytime I get the problem similar to the following.
Cross-thread operation not valid: Control 'ProgressBar1' accessed from a thread other than the thread it was created on.
I tried starting a new thread within the application following http://www.codeproject.com/Articles/15861/How-to-solve-quot-Cross-thread-operation-not-valid and I still get the same problem.
How can I turn my single threaded application into a multiple threaded application?
I am using vb.net 2008
|
|
|
|
|
A thread is a new process started by u and it can not access controls of thread who create it. but the child thread can return data to parent thread.
error "Cross-thread operation not valid: Control 'ProgressBar1' accessed from a thread other than the thread it was created on" thrown by your code is an example of it.
Solution: you can use BackgroundWorker class to reduce your problem. it will start a new thread and doesn't hang your application while searching and it can also return data to your application after completion of it's execution.
if you can work according to my suggesion then OK otherwise tell me, i will give an example code that will solve your problem.
|
|
|
|
|
The Invoke pattern;
Imports System.Threading
Public Class Form1
Dim MyNewThread As Thread
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MyNewThread = New Thread(AddressOf MyThread.MyThreadExecute)
MyThread.ThatForm = Me
MyNewThread.Start()
End Sub
Public Sub SetProgress(ByVal What As String)
If InvokeRequired Then
Invoke(New Action(Of String)(AddressOf SetProgress), New Object() {What})
Return
End If
Label1.Text = What
End Sub
End Class
Module MyThread
Public ThatForm As Form1
Public Sub MyThreadExecute()
Dim i As Integer = 0
Do
i = i + 1
ThatForm.SetProgress(i)
Thread.Sleep(100)
Loop
End Sub
End Module
|
|
|
|
|
we are developing an application which accesses local and network printers. How to read list of available printers in a machine and how classify them as local and network printers.
|
|
|
|
|
There's an example in the manual[^].
|
|
|
|
|
Thanks for the update. I got the list of printers using
http://www.cpearson.com/excel/GetPrinters.aspx[^]
But i need to find network and local printers and classify them different groups. How to find local and network printers from the list?
|
|
|
|
|
KASR1 wrote: But i need to find network and local printers and classify them different groups. How to find local and network printers from the list?
You can only get a list of apparatus that are "known" by the local installation. Some TCP/IP thingy will not be recognized, until the drivers are installed.
|
|
|
|
|
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
|
|
|
|
|