Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Datagrid Sample Code


I am using datagrid for first time in my form. When i am scrolling thru rows and clicking on cell it is showing error message which is datagrid related error. so i want some sample code thru which i can use datagrid control easily.
thanks
manish
INDIA




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Sample Datagrid Program
hi,

can you give sample codes for binding a recordset to a datagrid and also header formatting...thanks


sheila

ADO DataGrid Sample Doesn't Work
Hi,

I downloaded a simple VB program from MS website. It is about database connection using DataGrid and ADODC control.
When I run it on a Win2000 with Office2000, it works.
However, when I run it on a Win2000 (only OS is installed), it doesn't work. (no warning/error, just no data)

Does Office2000 update some system files?

any idea?

Thanks,
k

XML && VB Sample Code?
Hello,

I am new to XML, but have loads of experience with VB. I need to learn XML and would like to get my hands on some sample code, where VB6 uses XML. Can anyone point me in the right direction? I tried the knowledge base but there was nothing useful there.

TIA

Sample Code
Can someone or a few people please post some sample vb code from a .dll file that compiles properly. I am trying to create a dll, however I keep getting odd errors, so I first want to try compiling guaranteed code to see if it is my compilation method that is failing or the code I have written.... this is my first dll file.
Thanks in advance.

Sample Xml Code In Vb
hey, does anyone have some simple examples of vb code that

1) creates an xml document and writes something to it, and saves it somewhere

2) reads some xml document

or, if anyone knows anywhere on the net where i can find this information, i will greatly appreciate it.

thanks,

jeff

Code Sample?
Can someone post, or send me, a sample of an extraction of a comma delimited file? I've never done one and can't seem to find one elsewhere... thanks in advance.

Ado Sample Code
I need full sample code for ado objects
any ideas??
Thanks.
anny.

Sample Code
Hi all,
I want sample code for shut down PC from vb code,
thanx

Sample Code In VB
I am a beginner for VB but know COBOL programming. Could I get a sample VB program to develop a payroll master updation and write data to an Acess Database. Field names are Emp_no, Name, Basic.

Sample Code That Use ADO Object
Hi friends,
I need to see some sample code to learn how to use ADO in my VB code like I have to know how can I write my code like:


Code:
sql="SELECT * FROM " & dbtable
sql = sql & " WHERE " & dbfield
sql = sql & " LIKE '%" & dbwhere & "%'"

since legacy code is not good...

So could you please help me on this?

Many thanks,
Elahe

Code Sample Definition
Sub ONEVALUES()
Range("AY:AY").Select
Selection.Clear
Vals = Range("am39").Value
Range("ay1", Cells(Vals, 51)).Value = "1"
Range("ay1", Cells(Vals, 51)).Select
VAL1 = Range("am39").Value
End Sub


This assigns the value in cell am39 to variable Vals
Then the What does the Range function do?

I Am Looking For Nwtwork Sample Code In VB 6.0
anybody know where can I find a network administrator sample code in VB 6.0? I will apreciate if you guys tell me how can I get it.

Thanks, in advance


Edit by Moderator:
Please post VB6 questions, in the Legacy General forum.

Thank you.

Anyone Have A Sample Printer. Code Example?
i looked at a lot of tutorials and what not and im still not able to write out my own print layout..

i learn best when i see an example that i can relate to and understand!

would someone be willing to either write an example or show me a good example of a page layout using the printer.?

here is some of the code that ive been using, and experimenting with, i need to print labels as well and variable.. can anyone show me?


Code:
Printer.PaintPicture LoadPicture("C:WINDOWSsystemfileslogo.jpg"), 3200, 1

Printer.FontSize = 20
Printer.CurrentX = 10
Printer.CurrentY = 10

For i = 0 To inbound
Printer.Print strArray(i)
'when array reaches a certain amount start a new page cause it will run off first page, printer.newpage?
Next i
Printer.EndDoc

Barcode Sample Code
I try to write a barcode program & I need some sample / guideline.
10q

Why Does Sample Code Not Compile?
I took some sample code that did what I wanted (to find the associated application for a file) and tried to run it on my machine (WinXP, using wscript), and it doesn't compile (I've included all the code below so other people may use it, or if someone needs more information than isolated lines to answer the question).

Running it by double clicking on the file (called test.vbs) gives me:

Line: line 11
Char: character 17
Error: expected end of statement
Code: 800A0401
Source: Microsoft VBScript compilation error

It is complaining that "Private Declare" should be a full statement. Any idea why?

A second question if you'll allow me:
If I comment out the four lines starting with "Private Declare", I get the same "expected end of statement" error, but this time it is complaining about the "As Long" in the "Dim success As Long" line.

I assume both problems are related, but don't know what to try next. Do I have a version or configuration problem?

Regards,

Howard


Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright 1996-2003 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Declare Function FindExecutable Lib "shell32"_
Alias "FindExecutableA"_
(ByVal lpFile As String,_
ByVal lpDirectory As String,_
ByVal sResult As String) As Long

Private Const MAX_PATH = 260
Private Const ERROR_FILE_NO_ASSOCIATION = 31
Private Const ERROR_FILE_NOT_FOUND = 2
Private Const ERROR_PATH_NOT_FOUND = 3
Private Const ERROR_FILE_SUCCESS = 32 'my constant
Private Const ERROR_BAD_FORMAT = 11

Private Sub Command1_Click()

Dim success As Long
Dim pos 'As Long
Dim sResult 'As String
Dim msg 'As String

sResult = Space(MAX_PATH)

'lpFile: name of the file of interest
'lpDirectory: location of lpFile
'sResult: path and name of executable associated with lpFile
success = FindExecutableA("winhlp32.hlp", "c:winntsystem32", sResult)

Select Case success
Case ERROR_FILE_NO_ASSOCIATION: msg = "no association"
Case ERROR_FILE_NOT_FOUND: msg = "file not found"
Case ERROR_PATH_NOT_FOUND: msg = "path not found"
Case ERROR_BAD_FORMAT: msg = "bad format"
case else
if success >= ERROR_FILE_SUCCESS then
pos = InStr(sResult, Chr(0))

If pos Then msg = Left(sResult, pos - 1)
end if

End Select

MsgBox msg

End Sub

call Command1_Click

Need A Sample Tutorial/code
I'm trying to do a login page. The login page form consist of:-
1) Text box - Student ID
2) Text box - Password
3) Command button - Login

I have a database which consist of student ID and password.

Procedure,
When the user click on the Login button after key in the the student ID and password. The program will check whether the student ID match with the password. If yes a message box will pop up and display matched

*this is not my homework or assignment, actually i'm from electronic and electrical engineering. currently doing my project where i'm going to communicate my hardware with vb. so i would like u guys from computer field to guide me on doing the software part.

Thanks in advance!

MSchart (need Sample Code)
Guys,
I'm having trouble using Mschart. I want to create a relatively simple bar chart. Below is a sample of what the data looks like. I'm bringing in the data as a recordset.

Descr5/5/20065/6/20065/7/2008
Filler433138
Capper904167

The chart should be a multi column one, with descr on the x axis, value on the y axis and date as the legend.

Thanks,
MITech

Need Help Or Code Sample For Writeprocessmemory!
Hello all i'm new here and I am also new to visual basic. I was wondering if anyone could help me with the whole process with writeprocessmemory because for some reason I can't get the openprocess to open the process up. Please help and i will post code samples if I get a reply. Thank you....

Dan

EDIT :

For my Form_Load I have :


Code:

Private Sub Form_Load()

' Declare some variables we need
Dim hwnd As Long ' Holds the handle returned by FindWindow
Dim pid As Long ' Used to hold the Process Id
Dim pHandle As Long ' Holds the Process Handle

' First get a handle to the "game" window
hwnd = FindWindow(vbNullString, "GunBound")
If (hwnd = 0) Then
MsgBox "GunBound Is Not Running."
Exit Sub
End If

' We can now get the pid
GetWindowThreadProcessId hwnd, pid
If (pid = 0) Then
MsgBox "Couldn't Resolve A PID Number."
Exit Sub
End If

' Use the pid to get a Process Handle
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (pHandle = 0) Then
MsgBox "Couldn't Get A Process Handle."
Exit Sub
End If

' Now we can write to our address in memory
WriteProcessMemory pHandle, &H40B181, "Beans", 5, 0&

' Close the Process Handle
CloseHandle hProcess

End Sub



Also my module has this :

Code:

Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function WriteProcessMemory Lib "kernel32.dll" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Declare Function ReadProcessMemory Lib "kernel32.dll" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long

Opening Up Sample Code
I have started downloading some sample code, I open it and Winzip shows me several files, I open one that says form and it opens into VB, but if I try to run the program it always gives me an error. The most popular is "Compile error - sub or function not defined" Can anyone tell me how to look and run these sample codes. Thanks!!

Terminal Sample Code
Any idea where to find a sample terminal, hyperterminal like, program using plain vb code or Ms comm control ?

Thanks in advance

fazt_dot@yahoo.com

Need Help Deciphering Code Sample...
Dim sTemp As String, sTemp2 As String

Open "cool.exe" For Output As #1
Open App.Path & " ea.dll" For Binary As #2

While Not EOF(2)
sTemp = Input$(2000, #2) <----- What does Input$() do?
sTemp2 = sTemp2 & sTemp
Print #1, sTemp2;
sTemp2 = ""
If Len(sTemp) > 2000 Then
sTemp = ""
End If
Wend

Close #2
Close #1

Visio 5.0 Sample Code
I need to create a visio document from vb, if someone can help me with my Dim's and Set's, it would be greately appreciated.

Thank you.

Sample Code(login)
Is there a sample code when user needs to access a DB in VB and the user is not mapped to the correct network drive or not connected at all..Is there a code that enbles the user to get prompted to logon to to the server(mapping) with a user name and password?

Help Finding Sample Code
I'm sure that somewhere on this forum I've found VB sample code showing you how to place a graphic within a textbox by using various APIs to paint onto the textbox (for example, drawing a magnifying glass in a textbox to signify that you should enter a search term).

Unfortunately I can't find this article and now I'm thinking that I imagined it! Can anyone help me find it, or does it sound impossible and therefore probably never existed in the first place? - Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments

Unzipping: Sample Code?
Hi,

I have an FTP program that downloads updates from the web. These updates are in Zip format. I was just wondering what would be the code required to unzip those files also taking into consideration of users that don't have WinZip installed on that PC. Could this be done using PKzip?

Baz.

Sample Code Using AdArray?
Hi,

Does anyone have an example using adArray?


Thanks

Need Scheduler Code Sample
I need a sample code for scheduling events within an application. A user can select the days the scheduling will be active, a starting and ending time (24 hr format) and an interval.

What I want is a value that tells me the next time (and if possible date) when the event should occur.

The values of the starting and ending time are in hh:mm format (24 hr), the interval in minutes. The days are selected from checkboxes.

Handling of incorrect user input is already in the application, so it's not possible to have a starting time that is after the ending time and vice versa, as well as an interval that is larger than the time between the starting and ending time.


Thanks for your hint...


Jeroen.

VB Ledger Sample Code
Hello, Can anyone help me in finding sample VB5.0 code for developing accounting application, especially ledger module.

Quick reply would be greatly appreciated as I am in the middle of my project.

Thanks in advance,
Harish V.

Sample Code For MSFlexgrid
Where can i get sample code how to use msflexgrid to store data into my database.

Code Sample: Rounded Controls
This small demo project contains a module that can give any control a border with rounded edges, in the colour of your choice! It even works for controls in different parent objects (which was something you couldn't do with most other demo projects, like the one in this thread).

It's very short, clean, easy to understand and well commented. Hope you like it!

Note:
If you are planning to resize controls, and want to keep their rounded borders, you'd best call the drawing sub from both Form_Paint and Form_Resize (to avoid visual anomalies).
If you are not planning to resize controls, then to improve border stability, you can comment out a certain line in the module (you'll see which one).

Edit:
v0.90: release
v0.91: added Option Explicit, updated loop, cleaned up demo-form
v0.91: was bored so cleaned up the form once and for all

Sample Code To Close The Running .exe?
My form is an .exe that I have made and I would like to add a button to close the exe. (an exit button)

I've looked through my book and don't see one example of this

Sample Code For Ledger Development In VB5.0
Can I get the sample code for developing ledger application of Accounting in VB5.0. I am in the middle of my project. Quick reply would be greatly appreciated.

Thanks in advance,
Harish V.

Data Structures Sample Code?
Hello all, I'm looking for a site that has examples of data structures in VB.

Funds Distribution --- Sample Code
Have 16-variables all double.

1: BalanceDept1
2: OwingDept1
3: PymtDept1
3: BalanceDept2
4: OwingDept2
5: PymtDept2
6: BalanceDept3
7: OwingDept3
8: PymtDept3
9: BalanceDept4
10: OwingDept4
12: PymtDept4
13: BalanceDept5
14: OwingDept5
15: PymtDept5
16: TransAmt

Balance=Owing-Pymt

All dept-variables are extracted from a database, variable-Balance is user-defined.

TransAmt needs to be distributed in such a way that it first satisfies Dept1 (ie. BalanceDept1 = Zero),
then satisfy Dept2, Dept3,.....

Thus, payments distribution is priotized, ie. make BalanceDept1 Zero, then jump to Dept2, then Dept3,.....

When all 5-Dept balances are Zero, and still if TransAmt is not Zero or another transaction of TransAmt
then transfer everything to PymtDept1 --- thus making BalanceDept1 negative.

Would really appreciate if someone could put a sample code.

<P ID="edit"><FONT class="small"><EM>Edited by miky348 on 05/14/01 05:35 PM.</EM></FONT></P>

Request For Sample Code For Datareport
hello,

after hours of straggling and de-bugging, can someone please write a sample code for how to create a data report and a data enviorment???

assume the sql string is:
"select field1,field2 from myTable"
database name: MyDB

i will be very very thankfull for any help

WaveInAddBuffer (desperately Looking Sample Code)
Hello,

Where I can find and example of Wave In recording using:
waveInOpen()
waveInPrepareHeader()
waveInAddBuffer()
waveInStart()
MM_WIM_DATA (no timers, ok?)
....

If VB, of course. C++ examples works.

Sample Code For Edge Detection
Hi,
I'm a beginner in vb 6.0 and have got image processing assignment to do, could any one please, help me with a sample code for edge detection. Though not essential, it will be preferable if it comes with a bit of explanation.

Thanks alot

Sample Code For Printing Properties
could anyone just post a sample code for printing.. Please include FROM the declarations up to the setting up of paper sizes.. urgent pls.. thanks..

*STILL UNRESOLVED* Code Sample Do Not Work
I would be so very greatfull if someone could make this work, because I've tried almost everything with no luck at all:

http://www.vbweb.co.uk/show/16/11/

What I'm trying to do is enable multiple undo/redo in my RTB...

Screen Saver's Code Sample.
Does anyone know where to find Screen Saver's code sample?
Thanks.

Sample Code For Resize All Controls
Hi,

Can I get some sample code which will resize all controls in the form when you rezie form?.

Ex:If you double click on VB software it will automatically fits into the screen size(15",17" or 19") and it resizes all its controls on the form

Thanks.

On Error Problem + Sample Code
I have a problem with my On Error Goto statement.

I have a program that allows my mp3 tracks to be renamed but have an error trap that gives a useful message if it cant rename the track (because it is playing for example).
All the tracks get loaded into a listbox, you rename the tracks you want and hit the OK button. The program then trolls through the list and renames the tracks you have changed. Works perfectly unless it tries to rename a track that is playing.

I added the On error statement to display a message and continue with the rest of the track renaming. All seems great...

The problem............Once the message has come up correctly the first time, i comes up on every successive track it tries to rename even though those tracks arent playing. I want it to rename all that it can but just warn about the track it cant

The Code is as follows:

VB Code:
Private Sub CommandOK_Click()    Dim PathName As String    Dim OldTrackName As String    Dim NewTrackName As String    Dim NewAlbumName As String    Dim NewMP3StartPath As String        On Error GoTo Errorhandler        'First rename tracks    Index = 0    While Index < TrackList.ListItems.Count        PathName = Right(HTrackList.List(Index), Len(HTrackList.List(Index)) - InStr(HTrackList.List(Index), "||") - 1)        If Right(PathName, 1) <> "" Then            PathName = PathName & ""        End If        TrackName = Left(HTrackList.List(Index), InStr(HTrackList.List(Index), "||") - 1)        OldTrackName = (PathName & TrackName & ".mp3")        NewTrackName = (PathName & TrackList.ListItems(Index + 1) & ".mp3")    ' Add one as this array starts at 1!        If OldTrackName <> NewTrackName Then            Name OldTrackName As NewTrackName     ' Rename track.            NoChange = False        End If        Index = Index + 1    Wend        ' Now we Rename the Album but only if it has been changed    NewMP3StartPath = MP3StartPath    If Right(NewMP3StartPath, 1) <> "" Then            NewMP3StartPath = NewMP3StartPath & ""        ' Add a slash if one doesnt exist    End If        If AlbumName <> Browser.Albums.Text Then        NewAlbumName = NewMP3StartPath & AlbumName        Name NewMP3StartPath & Browser.Albums.Text As NewAlbumName     ' Rename album        NoChange = False    End If    Unload Me    Errorhandler:        MsgBox "The File " & OldTrackName & " could not be renamed." & vbNewLine & _        "This is probably because it is currently playing. Please rename this track after" & _        " it has finished."        Resume NextEnd Sub


Can anyone tell me why this is happening? Do I have to reset the error or something after the first time? The message should only appear once (if at all) as only one track will be playing at a time.

Regards

Sample Code To Read SMS Through GSM Modem.
Hi....

Can anyone pls help me with sample code in visual
basic 6.0 to read sms
using GSM Modem. Desperately require it very urgently
for my sms
application.



Many Thank's

Rajeev.

Sample Code For GPIB Implementation
Is there any sample code for implementing GPIB for power supply control from NI.

VB6 Crystal Report 9 ( Sample Code)
Dear All,

I have Crystal Report 9 and trying to display my Crystal Report on Visual Basic 6 form at print event. It is simple customer list report working fine out side the visual Basic environment.

But I don't know how to display and what code should i write in order to display report using Visual Basic Application.

Can anybody Expert provide me simple solution code to solve the problem. I am new to VB.

Best regards
Zahid

Sample Code For Implementing Threads In Vb6 0
i am using MFbus control in vb. how can i establish connection of mfbus by using thread. please send the code for threads using that mfbus1.5 control.
from
siva

Need Code Sample Of GetPrivateProfileString In VB5 INI File
I lost the harddrive holding all of my VB5 reference sample code and I'm trying to find a good code sample of the GetPrivateProfileString for INI files. I need the whole chunk of code for it, including the defining and assigning of all string values for the GetPrivateProfileString statement.

Example:

Public Function Read_INI()

    lpAppName = App.EXEName
    lpKeyName = ShellExpression1
    lpString = HyperShell1
    lpDefault = ""
    lpReturnedString = Space(nSize)
    nSize = Int(256)
    lpFileName = App.Path + "" + "MultiCast1.INI"

    GetPrivateProfileStringA(string lpAppName, string lpKeyName, string lpDefault, lpReturnedString, nSize, string lpFileName);
    

End Function

I know that this sample of code isn't quite right, but I can't remember how it all went. This is the first programming I've done in a while, but if you could provide an example like the sample I gave above, I would be ecstatic! And remember, this is VB5, not 6.

Thanks!
Sol
 

Need VB Sample Code To Get Bytes Sent / Received
I would appreciate a simple piece of code (VB) to provide network bytes sent and received from Performance Counters on a workstation (or is there another place?)

Have Win-2000 application using MS-Access database on server and depending on size of backend database, there are some very ugly transfers of data.  Most likely culprit is poorly written SQL (gee, let's get all fields in all records...), but with over 900 queries, I dread the manual approach.  

I already have code that will automatically insert traces into all subroutines in all modules and provide lapse times, but now would like to get bytes over the network (one look at the lights on the NetGear switch will blind you).

Thank you for your assistance.

Sample Code For Slider{Resplved0
Hello All members
How can i user Slider!!!
Thanks alot for advice

Egyptian Man

Edited by - khaledagwa on 8/31/2004 6:30:31 AM

Copyright 2005-08 www.BigResource.com, All rights reserved