.NET Thread

WeatherMan

Active Member
I'm making an application for a software development class and really behind right now.

Got the design done, but can't figure out the code!

Here is what I have done so far:



Could someone assist me with some code for multiplying the 'Cost' (Label) by the 'Quantity' (Combobox) so that the £VALUE is entered into the Total column, which is a label.

Thanks :)
 

Cromewell

Administrator
Staff member
Probably something like this: CType(Combobox.SelectedValue, Integer) * CType(Label.Text, Double)
 

M1kkelZR

Active Member
ey guys, I'm getting an error when I want t add a file to my dataGridView that I can't add any data because it is databound. I've been working around this but still gives me the same error. heres the snippet of the code:

Code:
SQLiteDataAdapter dAdapter = new SQLiteDataAdapter();
        SQLiteConnection connect = new SQLiteConnection("Data Source=C:/Users/Michael/Desktop/TestingSQL3/TestingSQL3/test.s3db");
        BindingSource bSource = new BindingSource();
        DataTable dTable = new DataTable();
Code:
  private void btnOpenLog_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
            {
                String sLine = "";
                try
                {
                    System.IO.StreamReader FileStream = new System.IO.StreamReader(openFileDialog1.FileName);
                    sLine = FileStream.ReadLine();
                    string[] s = sLine.Split(';');
                    for (int i = 0; i <= s.Count() - 1; i++)
                    {
                        DataGridViewColumn colHold = new DataGridViewTextBoxColumn();
                        colHold.Name = "col" + System.Convert.ToString(i);
                        colHold.HeaderText = s[i].ToString();
                        dataGridView1.Columns.Add(colHold);
                    }
                    sLine = FileStream.ReadLine();
                    while (sLine != null)
                    {
                        dataGridView1.Rows.Add();
                        for (int i = 0; i <= s.Count() - 1; i++)
                        {
                            s = sLine.Split('|');
                            dataGridView1.Rows[dTable.Rows.Count - 1].Cells[i].Value = s[i].ToString();
                        }
                        sLine = FileStream.ReadLine();
                    }
                    FileStream.Close();
                }
                catch (Exception err)
                {
                    System.Windows.Forms.MessageBox.Show("Error:  " + err.Message, "Program Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

If anyone can help me with anything would be cool.
 
Using Visual Basic.NET in Visual Studio Express 2010...

Can some one help instruct me on how to construct a function that can get me details about my PSU, and Video Card, I want to use that function in the Form1_Load code to change a label (i.e. Label1.text = GPUName()) to each spec that I am able to give, I do not know where to start, I have already developed how to get CPU threads and Usage, and Memory Usage but this is from the registry and I do not know how to use anything like WMI and make it work...I dont know where to start -.- I only started learning a few weeks ago :/

Cheers for any help!

(If you want to have a look what I have done, its the most recent post here: http://ashleystechtalk.blogspot.co.uk/p/aperture-science-release-log.html )

Ash
 

M1kkelZR

Active Member
Well I have a thing where I can get the name of the GPU etc, which is easy. Just look for WMI Controls (a nice example: http://www.dotnetheaven.com/article/windows-management-instrumentation-in-vb.net) For usage I need to figure out, I do use C#.net so I wont be able to help with VB.net but as far as I've seen its pretty much the same.

Here my Example of the WMI in c#:
A using declaration:
Code:
using System.Management;

So you'll need a searcher, so use this:

ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * from Win32_VideoController");
This gets the Name of the GPU, at the moment I'm at work so it would say GeForce 9300 GE.

Now you want to change the Label name to say GeForce 9300 GE (or whatever GPU you have installed)
Code:
            foreach (ManagementObject gpuObj in searcher.Get())
            {
                lblGPU.Text = (gpuObj["VideoProcessor"].ToString());
            }
This is all C# but its basically the same in VB.net. I'm still trying to figure out how I can get some clock speeds etc to show and a way to get the GPU/CPU/RAM usage + voltage/wattage on each component.

Hope I helped a little if not, then just use the delete button in your brain and get rid of this knowledge :p
 
Last edited:
Well I have a thing where I can get the name of the GPU etc, which is easy. Just look for WMI Controls (a nice example: http://www.dotnetheaven.com/article/windows-management-instrumentation-in-vb.net) For usage I need to figure out, I do use C#.net so I wont be able to help with VB.net but as far as I've seen its pretty much the same.

Here my Example of the WMI in c#:
A using declaration:
Code:
using System.Management;

So you'll need a searcher, so use this:


This gets the Name of the GPU, at the moment I'm at work so it would say GeForce 9300 GE.

Now you want to change the Label name to say GeForce 9300 GE (or whatever GPU you have installed)
Code:
            foreach (ManagementObject gpuObj in searcher.Get())
            {
                lblGPU.Text = (gpuObj["VideoProcessor"].ToString());
            }
This is all C# but its basically the same in VB.net. I'm still trying to figure out how I can get some clock speeds etc to show and a way to get the GPU/CPU/RAM usage + voltage/wattage on each component.

Hope I helped a little if not, then just use the delete button in your brain and get rid of this knowledge :p

All of it just gives errors :/ System.Management is a namespace and not a expression one says and then searcher needs to be inside parenthesis or whatever :/ cheers anyway, dont think I'm gonna be able to do it :/
 

M1kkelZR

Active Member
All of it just gives errors :/ System.Management is a namespace and not a expression one says and then searcher needs to be inside parenthesis or whatever :/ cheers anyway, dont think I'm gonna be able to do it :/

I did say it is C#.net, the base is the same. Here a few links for VB.net and WMI etc:
http://www.freevbcode.com/ShowCode.asp?ID=4571
http://www.codeproject.com/Questions/292691/Help-with-wim-vb-net-coding
http://vbcity.com/forums/t/70161.aspx
http://www.emmet-gray.com/articles/wmi_intro.htm

most of it is the same but some explained differently.
 
555191_348723061912270_826572244_n.jpg


What other things can I add for computer info? Its VB.NET so any ideas are appreciated :)
 

M1kkelZR

Active Member
*snip*

What other things can I add for computer info? Its VB.NET so any ideas are appreciated :)

you could include a HDD read/write speed reader for current movements etc. Fan Speeds for fans you have.

All you need to do is just think of stuff you would want to see in your program :)
 
you could include a HDD read/write speed reader for current movements etc. Fan Speeds for fans you have.

All you need to do is just think of stuff you would want to see in your program :)

How would I do that?

I have only properly been teaching myself VB.NET for 2 weeks :p
 

M1kkelZR

Active Member
How would I do that?

I have only properly been teaching myself VB.NET for 2 weeks :p

there is a whole world of codez on the internetz, but because this is hardware based everything is used with the WMI.
Just have a google around for some tutorials and stuff for WMI.

I also found this: WMI Code Creator, maybe its worth looking at :)
 
Visual Basic Question

In VB.NET, how would I say:

Code:
if CPUPercent.text = "0%" to "10%" then
CPUPercent.fontcolor = red
end if
if CPUPercent.text = "11%"-"20%"
then ...

You get the picture. I have used a code to produce a CPU usage percentage, and I want it to change colour as the CPU usage percentage raises. The answer to the % processor time query is set as a text answer though.

What I have so far is:
34qtzth.jpg

It is basically a small widget that sits on the desktop that is trained to monitor CPU and RAM performance for my Server.
 

bradleyhand

New Member
Hi guys I'm doing a computer project in school.

It is just to create a website. I have used basic html and js, and I wanted to use basic ASPX too in some areas like reading user inputs, mainly because i want to use a WEB FORM. ASPX has been taught by my lecturers and I should use it to get higher marks in my project. So I decided to use it.

I have problems With ASPX.NET in My Microsoft VS.
It only works when I open it with visual studio and from there, I click this 'view in browser' option, which directs to my browser. The Content are like labels and textboxes and dropdownlists.

However it does not work properly (but it runs) when I open the aspx file from the file folder (finding the directory of the aspx file and opening it with 'open with..').
it runs, but it prints the first line which it should not
The first line is:

<%@ Page Language="C#" AutoEventWireup="False" Codebehind="Default2.aspx.cs" Inherits="Default2" %>

It also prints words if I just type below the first line. It is seems to be acting like a HTML file.
What should I do now?

when I use the computers in school which have Microsoft VS, it works.
But mine doesn't.

Maybe I didn't downloaded it properly. My friends say that even if I download VS, I would have to download some other stuff. Idk im not sure abt this just saying if it has got to do with my problem.

Pls Help! This is important! My Project Is due next Monday and i do not want to have bad results! and sory if my English grammer and sentence constructions are bad. i'm not a language person.. >.<

ty
 
Last edited:

Cromewell

Administrator
Staff member
I don't know how your computers at school are set up but if you don't have a webserver hosting your project (with .NET framework configured), opening the asp/aspx file won't work. Starting VS and telling it to view project starts up a temporary webserver with everything it needs.

Also, moved to the correct thread :)
 

bradleyhand

New Member
so is this NET framework a webserver? Do I download it like downloading java? I just want my webform to work!

ty

O yeah I think I have Netframework 4 when I try to create a webform in VS, so do I download 4.5? o yeah and I did not use the Visual Studio for my project at first bcause I didn't download it. I use my notepad because I thought I just had to use css html and js until when the lecture said abt the aspx thingy then I had no idea how to do it with basic tools. then my classmates helped me to download the visual studio IDE. So basically.. I have my files in just a random folder. It is not like a Microsoft visual studio project. So when I make an aspx file, I just copy paste the aspx and aspx.cs into that random folder. Is this alright? am I doing things wrong?

tyty

edited: hey I tried downloading 4.5 and windows said that I already have it. mayb bcause im using windows8.
edited:Hi administrator, is that a job?
 
Last edited:

bradleyhand

New Member
hi administrator,
I have consulted a friend and now I have a clearer idea on what u meant.
Now I have a real problem.
with this error message that I did not get last time when I used the webform.
"
This page contains the following errors:

error on line 1 at column 2: StartTag: invalid element name
Below is a rendering of the page up to the first error.
"
 

Cromewell

Administrator
Staff member
It sounds like you've probably got some server configuration to do yet.

You already have the .NET framework installed, so that part is good. The second part of the problem is having a webserver configured to use it. I have stood one up with duct tape and bubble gum :p

Basically, you go to Add/Remove Programs -> Add Windows Components -> find IIS (internet information services) and install it.

Then there's some monkeying around to the default website (this is the duct tape and bubblegum part) to tell it what framework to run applications with, and you add your project as an application. From what I remember, it's a lot of going in and out of GUI elements from the IIS management console.
 

bradleyhand

New Member
i cant add it but i have gotten it in one of my windows features. So i on this IIS, and most of its components but i still got that error! Any advice>?
tyty
O i just realized that in IE by aspx file does not show the above error, just blank page. Except when im using google chrome, error is shown.

If this don't work.. I think i'll have no choice but to stop using aspx for my project. :(
bye bye A.
thanks anyways for helping alot.
tyty

Hey i just made a virtual directory in iis in my file folder. Will tell u if it worked out!

.......didn't
 
Last edited:

Cromewell

Administrator
Staff member
In the IIS management console, there should be an option for a new application under your website. That's the one you want to make.
 
Top