|
Sir,
When i click on the particular row of the datagrig all the data of that row should display in the various textboxes.For that please send the code.
Thanks and Regards
Amaneet Brar
|
|
|
|
|
Create an event handler for the data grid. EIther Click or DoubleClick
Use this syntax to extract the data from the current row.
DataGrid.Item(Datagrid.CurrentRowIndex, ColumnNumber)
So if the First name is in Column 1 do
TextBox.Text = Ctype(DataGrid.Item(datagrid.CurrentRowIndex, 1), String)
Hope this helps
-- modified at 4:51 Friday 9th June, 2006
|
|
|
|
|
Sir,
Can we do addition , deletion , edition , updation of data in excel sheets programically as we do in access database by oledbconnection.If yes can you please send the code link?
Thanks and Regards
Amaneet Brar
|
|
|
|
|
Hello.
It may help if you know a bit of VBA for excel as the coding is very similar.
1. Create a reference to Excel Object library in the COM tab when you write click references.
2. Create the objects in code
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
3. Set the objects
xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
xlBook = CType(xlApp.Workbooks.Open(xlfile), Excel.Workbook)
xlSheet = CType(xlBook.Worksheets(1), Excel.Worksheet)
xlFile is the path name of the file you want to open. If you want to create a new xlfile type
xlbook = Ctype(xlApp.Workbooks.Add, Excel.Workbook)
4. To set the Values of cells use
xlsheet.Cells(Rowindex, ColIndex).Value = "abc"
Have a look in the help section of the "Visual Basic Editor" in excel to see how to change values and move around the sheet etc.
Hope this helps
-- modified at 2:41 Friday 9th June, 2006
|
|
|
|
|
Sir,
can you please send any link or the detailed code for adding , deleting , updating the records in the excel sheets?
Thanks and Regards
Amaneet Brar
|
|
|
|
|
When you say adding, deleting and updating, do you mean changing the values in particular cells and worksheets?
Do you need to update formulas, delete entire rows or columns or applying formats to the cells. If you can give me a list of the functions you want to do I can tell you the specific code for them.
|
|
|
|
|
Sir,
I want the complete code for that what you mentioned.
If possible please send the code.
Thanks and regards
Amaneet Brar
|
|
|
|
|
Are you happy with what I said above for creating the reference and setting the objects to create the Excel spreadsheet?
|
|
|
|
|
|
No problem.
Right click on References in the solutions explorer and select add reference.
Click on the COM tab and scroll down until you find "Microsoft Excel Object library". if there are a couple selcet the highest version. This will create a reference to the Excel library.
In your code create some variables below:-
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Create a variable that hold the path of the spreadsheet you want to open (xlFile)
Set the xl Variables
xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
xlBook = CType(xlApp.Workbooks.Open(xlfile), Excel.Workbook)
xlSheet = CType(xlBook.Worksheets(1), Excel.Worksheet)
This will create the xlspreadsheet in the background. It will not be visable until you say "xlApp.Visible = True"
To put a value into a cell type
xlsheet.Cells(rowNumber, colNumber).Value = ......
To put in a formula Type
xlSheet.Cells(rowNumber, colNumber).Formula = "=A1 + B1" as you would in excel
To delete an entire row
xlSheet.Cells(rowNumber, colnumber).EntireRow.Delete(xlShiftUp)
To delete an entire column
xlSheet.Cells(rowNumber, colNumber).EntireColumn.Delete(xlShiftLeft or xlShiftRight)
To add a worksheet
Dim xlNewSheet as Excel.Worksheet
xlNewSheet = Ctype(xlBook.Worksheets.Add(), Excel.Worksheet)
To change the Name of a worksheet
xlSheet.Name = "My New Sheet"
Is there anything else you would like to do?
|
|
|
|
|
Hello All!!
I have created a windows service and the problem is when I log off my system account in which the service is currently running, the service stops. Why is this so? I want my service to run independent of my system account.
Thanx in advance
regards
Mubashir
Storan Technologies (USA)
|
|
|
|
|
It stops because you have logged off and it was running under those credentials. Logging off destroyes the process under which all sub processes run so therefore your service dies.
If you want it to run regardless of the logged on user, you'll need to change the service properties so that it runs under the localservice userid etc..
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
This doesn't make any sense. A true service application runs regardless of who is logged in and it keeps running even if the user at the console logs off. Your description makes me think that you actually wrote a Windows application and are running it under the logged in user at the console, possibly out of the StartUp folder.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
If it has method. can you tell me some example?
|
|
|
|
|
|
|
I am writing my first code in VB.NET and was doing quite well until now. Can someone please tell me how to implement the following.
Set dwData field to a value.
Set lpData to point to filename string
Set cbData to filename string length (add 1 for trailing zero)
I have read the article Single Instance App with Command-Line Parameters
By Richard Deeming wich gave me some ideas but its not quite doing what I hoped.
Cheers
|
|
|
|
|
smokepipes,
In richards code it is like this:
Line --- mMain.vb -- from TestSingleInstance By Richard Deeming
109 Dim CD As COPYDATASTRUCT
110 With CD
111 .dwData = 0 '<<-- sets "Value to zero"
112 .cbData = B.Length '<<-- sets "filename string length"
113 .lpData = lpB.ToInt32 '<<-- sets "pointer to "filename string" converted to an "integer 32"
114 End With
Adding "1 for trailing zero" to the "filename string length" would cause the function SendCDSToWindow, to fail.
"its not quite doing what I hoped" <<-- What did you hope it would do?
progload
|
|
|
|
|
Thanks for the reply.
What I am trying to do is set up a data stream from another application(Flight Simulator). I have used the findwindow function in the win32 api and now I need to establish the connection to the Simulator to get data from and send data to the Simulator. I dont think that this is generaly what Richards code does but its the closest thing I could find. I have some code in c++ if it helps and I have tried to convert it but c++ doesnt mean a thing to me at the moment. I am still getting to grips with the basics of VB.NET
#include <windows.h>
#include "FlightSimLink.h"
const char* sFSMainClass = "FS98MAIN";
const LET_START_VIDEO_RECORDING = 0x0001B001;
const LET_STOP_VIDEO_RECORDING = 0x0001B002;
const LET_START_VIDEO_PLAYBACK = 0x0001B003;
const LET_STOP_VIDEO_PLAYBACK = 0x0001B004;
const char sFSHandleMagic[] = {'<', 'H', 'A', '>'};
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFlightSimLink::CFlightSimLink()
{
}
CFlightSimLink::~CFlightSimLink()
{
}
void CFlightSimLink::Tell(FS_ACTION action, const char* filename)
{
HWND hWnd = FindWindow (sFSMainClass, NULL);
if (!hWnd)
throw "FlightSim is not running";
COPYDATASTRUCT cpdata = {0, 0, 0};
switch (action) {
case FS_START_RECORD:
cpdata.dwData = LET_START_VIDEO_RECORDING;
cpdata.lpData = const_cast<char*>(filename);
cpdata.cbData = strlen (filename) + 1;
break;
case FS_STOP_RECORD:
cpdata.dwData = LET_STOP_VIDEO_RECORDING;
break;
case FS_START_PLAYBACK:
cpdata.dwData = LET_START_VIDEO_PLAYBACK;
cpdata.lpData = const_cast<char*>(filename);
cpdata.cbData = strlen (filename) + 1;
break;
case FS_STOP_PLAYBACK:
cpdata.dwData = LET_START_VIDEO_PLAYBACK;
break;
default:
throw false;
}
SendMessage (hWnd, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cpdata);
}
void CFlightSimLink::Tell(FS_ACTION action, HANDLE handle)
{
char MagicName[sizeof (sFSHandleMagic)+8+8+1];
memcpy (MagicName, sFSHandleMagic, sizeof (sFSHandleMagic));
wsprintf (MagicName + sizeof (sFSHandleMagic), "%08.8X%08.8X", (DWORD)handle, GetCurrentProcessId ());
Tell (action, MagicName);
}
I hope this may shed some light on what I am trying to do.
Cheers
|
|
|
|
|
I want to develop a software in VB.NET 2003 (windows form not web form) which check on internet on my website whether new pictures are available on my website & if new pics are available, download them to a specified folder on user comp (eg. c:\pics).
I got an idea of this by simply adding a text file on my website/webserver & whenever i add new pics, i also add its location (http://www...) in that text file (one pic's location on each line). And my program reads that text file to find out whether there are all files located in that text file present on user's comp (c:\pics).
So now anybody, please tell me with coding how can i do this. Tell me how to retrieve that text file & new pics through internet & also how can i read that text file & compare it with pics in user's comp. Please, anybody HELP!
Iftikhar Ali
-- modified at 14:35 Thursday 8th June, 2006
|
|
|
|
|
i a vb express 2005 programming
i want to write a program to read a file and store contents file in a array.
eg :
i have a coba.txt file : abcdefgh
i want to make array baca_coba,
baca_coba(1) = a
baca_coba(2) = b
baca_coba(3) = c
baca_coba(4) = d
baca_coba(5) = e
...
i write program :
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FileName = "F:\sementara\coba.txt"
openFileDialog1.FilterIndex = 1
Dim encoding As System.Text.Encoding = System.Text.Encoding.Default
Dim filen As New StreamReader(openFileDialog1.FileName, encoding)
Dim i As Integer
Dim baca_coba(),baca As string
For i = 1 To 10
baca = Int(filen.Read())
baca_coba(i) = chr(baca)
Next
but my program is error, how to make a program to this problem?
if i have a file with unknown unicode. how to write program to know
what type unicode from that file.
eg : from file baca_coba file above, when i click button, a message show with
information: BigEndian unicode
|
|
|
|
|
Why do you need an array to store each character? Just do:
Dim s as String = filen.ReadToEnd()
You can index the string as if it were a character array.
|
|
|
|
|
i want to add sound file to my application and work in form load how?!
ma_refay
|
|
|
|
|
Put it in resource somekinda res type "Wav" File and extract it when form is loading
Dim S as string
S=strconv(LoadResData(ResouceID,ResourceType In Here EG:"Wav"),vbUnicode)
Get the function SndPlaySound From api viewer.
and At the form_Load
sndplaysound(s,SND_ASYNC or snd_memory);
like that.simple
Kanchana
-- modified at 18:22 Thursday 8th June, 2006
|
|
|
|
|
hi i want to use currencymanger in my project so when i add new product to my dataset and before i update the dataset to databse i can move between theses products i add there for buuton in the form to move first ,last ,next ,previous so when i add new projeect the label that dir what record i have now and all record like this '5 of 17'
the error is when i try to add new product he add it but he edit in the first product in dataset because i don't know to told code to add new item to currency manger when i add new product and set focus on the new poistion
the code i use
" dim cr as currencymanger"
"cr=me.bindingcontext(datasetname,tablename)"
if i try to use the statement "cr.addnew" i have error because i use sqldataadapter to add new rows and add these rows to dataset hthe .net told me that some parameters can't alloe null inc ase of using "cr.addnew"
thanks and sorry for long
ma_refay
|
|
|
|