Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all 27206 articles
Browse latest View live

VS 2012 Specific word

$
0
0
hey,
I'm building a Html Editor program, and i can succed to make if in richtextbox1 there is word with name "!doctype html" then he will blue if only one letter is missing he will turn to black.
thnx to helpers

[RESOLVED] [VB.net - WebBrowser Control] Can't Click Element on TP-Router Page.

$
0
0
Hello,

I have problem clicking Submit button on TP-Router Page (192.168.1.1)

That's how the code is showing in webbrowser (Right Click > View Source)

Code:

<table width="760" border="0" align=center cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="150" class="light-orange">&nbsp;</td><td width="10"  class="light-orange"></td><td width="150" class="tabdata">&nbsp;</td><td width="10">&nbsp;</td><td width="440" class="tabdata">&nbsp;</td></tr></table><table width="760" border="0" align=center cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="160" height="42" class="black">&nbsp;</td><td width="160" class="orange">&nbsp;</td><td width="440" class="orange">
<INPUT TYPE="HIDDEN" NAME="BridgeFlag" VALUE="0"><INPUT TYPE="BUTTON" NAME="SaveBtn" VALUE="SAVE" onClick="uiSave()" class="sbutton"><INPUT TYPE="BUTTON" NAME="DeleteBtn" VALUE="DELETE" onClick="doDelete()"></td></tr></table></div><INPUT TYPE="HIDDEN" NAME="wanIGMPQitFlag" VALUE="0"><INPUT TYPE="HIDDEN" NAME="wan_PVCO_Flag" VALUE="0"><INPUT TYPE="HIDDEN" NAME="PageLockValue" VALUE="0"></form><script language="javascript" src="/basic/tc2wanfun.js"></script>

i want to click Save Button

Code:

<INPUT TYPE="BUTTON" NAME="SaveBtn" VALUE="SAVE" onClick="uiSave()" class="sbutton">
I am using this code but its return this error ( Object reference not set to an instance of an object. )

Code:

WebBrowser1.Document.GetElementById("SaveBtn").InvokeMember("onclick")

Show user what key is pressed

$
0
0
Hello,

I'm trying to make a form where the user can press *ANY* key on the keyboard and the form will respond telling the user which key was pressed..

It sounds fairly simple, BUT I need EVERY key to work, including Windows Key, the problem is when the Windows key is pressed the form loses focus because the Start menu appears.

Is there any way to prevent this from happening?

I do not want to disable the Windows Key because I need the form to detect and report the key press

Thank you.

Where is the mistake ?

$
0
0
In PrintDocument there are 5 Pages.

I am triny to Get image of PrintDocument Pages.

when I try to Get image of this pages I use this code (found internet). code Saving Files in this names Look1, Look2.....

When I debug program click Button1 Program run well. And PrintPreview show 5 Pages. Page:1 , Page:2 , Page3 .....

But Only save 1 Page in the Name Look0 and On Saved image appear Page:0 but on printpreview Page:1 appearing

where is the wrong ?


Code ;


Option Strict Off

Public Class Form1
Dim totalPages As Integer = 5
Dim page As Integer
Dim maxPage As Integer
Dim myfont As Font


Dim pdoc As New Printing.PrintDocument()

Friend WithEvents ppc As New Printing.PreviewPrintController()

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim ppd As New PrintPreviewDialog
pdoc.PrintController = ppc

AddHandler pdoc.PrintPage, AddressOf pdoc_PrintPage
AddHandler pdoc.EndPrint, AddressOf XxX

pdoc.Print()
pdoc.PrintController = New Printing.StandardPrintController

page = 1
maxPage = totalPages

ppd.Document = pdoc
ppd.ShowDialog()

End Sub


Private Sub pdoc_PrintPage(ByVal sender As Object, ByVal e As Printing.PrintPageEventArgs)
myfont = New Font("Lucide Console", 72)
Dim g As Graphics = e.Graphics
g.DrawString("Hello, " & vbCrLf & "Printer" & vbCrLf & "Page: " & page, myfont, Brushes.Black, RectangleF.op_Implicit(e.MarginBounds))
page = page + 1
e.HasMorePages = (page <= maxPage)
End Sub


Private Sub XxX(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)

Dim ppi() As Printing.PreviewPageInfo = ppc.GetPreviewPageInfo()
For X As Integer = 0 To ppi.Length - 1
ppi(X).Image.Save(Application.StartupPath & "\tmp\look" & X.ToString & ".jpg")
Next

End Sub



End Class


Thanks Advance.

webbrowser1 keeps returning to the same webpage

$
0
0
Am making a movie library that populates a local database. The program is pulling info for different movies from the imdb.com website. No matter what I try the webbrowser1 keeps going to the same movie info page.

Been battling this for a couple days. This seems to be a problem a lot of people run into and all the ideas I have tried do not resolve this.

This is where I am at:

Code:

            txtMovie.Text = ""
            System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 8")
            WebBrowser1.DocumentText = Nothing
            WebBrowser1.Navigate(New Uri(GlobalVars.newMovieData & txtMovie.Text))
            WebBrowser1.Refresh(WebBrowserRefreshOption.Completely)

line 1: Clears the web cache from the computer.
line 3: Grabs the movie title from a text box in the program I want info on.
line 4: Latest attempt to get this to visit a different website.

The above code is in a Button Sub that resets all the variables back to their original empty state before attempting to visit a different website.

Thanks in advance :)

Create Unique Field

$
0
0
I've created a 'username' field that will be auto-completed based on first and last name in my form text fields, so it starts as Me.firstname + Me.lastname

What I'd like to do, is verify that no one else has that username first. If they do, I want to loop through their first name, adding a character to the username until it's unique.

For example, lets say I enter:

John Smith... his username would be jsmith - check the database - no values so he gets jsmith

now I go to enter Jane Smith, but when the 'unique' check happens, she can't be jsmith, because there already is one... so it appends the second character to her name, she would be: jasmith.
if I entered June Smith, she would be jusmith, because jsmith is taken, but jusmith is not.

Now, if I wanted to enter Janice Smith, she would end up being jansmith, because jsmith is taken, it tries jasmith, thats taken, so it moves to jansmith.

Does this make sense?

How would I make this type of "recursive" check?

VS 2008 Remove spaces?

$
0
0
I don't think this is possible, but I thought I'd ask. I'm copying text from various PDF files that I want to put in a text file so it's where I want it. This means whole bunches of changes, mainly putting the text on one line instead of a lot of lines. That's no trouble. The problem is that sometimes I get text that looks like this:
O t h e r s set o u t i n t o t h e w o r l d t o l e n d t h e i r t a l e n t s to t h o s e w h o n e e d it m o s t , w h e t h e r t h e f o t k of a f r o n t i er

Which should, ultimately, look like this:
Others set out into the world to lend their talents to those who need it most, whether the fotk of a frontier

Yes, I know 'fotk' should be 'folk', but I'm not asking for spelling correction on top of fixing this mess.
Is there any chance of fixing this with code, or am I better off when I see this just removing all the spaces and then going in manually and adding them after?

Sending String Data from a VB6 program to a VB.NET program

$
0
0
Hi All,

My company is using a program written in VB6 nearly 20 years ago (not written by me but I have access to the source code and a copy of VB6). The program prints a document after data is entered into a database. I've written a new program in VB.NET that makes graphs of historical data based off the same database that the VB6 program uses. I would now like to link these 2 programs.

As the VB6 program has a interface that everyone in my company is used to I'd like to keep that but when a user presses print on the VB6 program I want the Item name variable, date variable and a few others passed into the .NET program so that that I can print out the associated graphs.

So really what I want is advice; what's the absolute simplest way to pass data from the old program to the new one?

Cheers

Steve.

displaying pdf in browser

$
0
0
I'm having an odd problem that occurs on some machines, but not others. Basically I have a form that has an embedded browser. I download a pdf from a website and then save on the local machine then navigate my browser to that file to open the PDF. Now it works perfectly well on my machine (PDF opens in browser) but on another machine, it fails to navigate to the file and then opens the file in adobe pdf viewer. My code is pretty simple:

This is the bit that calls my form
Code:

Dim pdfinbrowser As newLabelForm = New newLabelForm
                Dim fullpath As String = Path.Combine(tempdir, filename)
                pdfinbrowser.displayPDFFile = fullpath
                MsgBox(fullpath)
                pdfinbrowser.Show()

and this is the entire code of the form

Code:

Public Class newLabelForm

    Private pdfpath As String = ""
    Public WriteOnly Property displayPDFFile As String
        Set(value As String)
            pdfpath = value
        End Set
    End Property

    Private Sub pdfdisplay_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        pdfBrowser.Navigate(pdfpath)
    End Sub

End Class

can anyone see an issue here? or is it perhaps down to the directory where I am saving the file/permissions or something?

Print Rdlc report without showing preview vb.net

$
0
0
i made a project to print an invoice but im trying to print my report without showing print preview in reportviewer, can anyone help me! here is my code i used it to print:

Code:

Dim ds As New DataSet1
    Dim dt As DataTable = ds.Tables(0)

    If Cn.State = 1 Then Cn.Close()
    If Rs.State = 1 Then Rs.Close()
    Cn.Open(constr)
    Rs.Open("Select * From tbltemp", Cn, 1, 2)
    For x = 0 To Rs.RecordCount - 1
        Dim r As DataRow = dt.NewRow()
        r("itemcode") = Rs.Fields("itemcode").Value
        r("itemname") = Rs.Fields("itemname").Value
        r("itemunit") = Rs.Fields("itemunit").Value
        r("itemsize") = Rs.Fields("itemsize").Value
        r("itemqnt") = Rs.Fields("itemqnt").Value
        r("reqdate") = Format(Rs.Fields("reqdate").Value, "dd/MM/yyyy")
        r("ava1") = Rs.Fields("ava1").Value
        r("ava2") = Rs.Fields("ava2").Value
        r("rejust") = Rs.Fields("rejust").Value
        Rs.MoveNext()
        dt.Rows.Add(r)
    Next
    Rs.MoveFirst()

    frmreport.ReportViewer1.LocalReport.DataSources.Clear()
    frmreport.ReportViewer1.LocalReport.DataSources.Add(New  ReportDataSource("DataSet1", ds.Tables(0)))      frmreport.ReportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout)
    frmreport.ReportViewer1.RefreshReport()

    Cn.Close()
    frmreport.Show()

VS 2015 Trying to Make A Client Management Software

$
0
0
Hello.

Basically put, I am trying to make a software that can manage clients that connect to it. A server if you will. Basically put, this program would be able to list the IP's of the clients it connects to and manage them in different ways.

Background wise, there is a program that acts like a chat room, it allows people to talk to each other and move to different rooms within the "server" It also can dictate backgrounds for each "room" and allow people to change ambient music. All connected clients can see the set background for that area and all people can hear the music. People can also choose differing avatars.

Now I'm not trying to make that program.

I'm trying to make the "server" for it. I.E : The program that handles the clients that connect using this program. This program will basically dictate...

The amount of "songs" and which songs a user can select in their list.
The amount of areas and which areas a user can switch between.
The amount of avatars and which avatars the user can choose.

More importantly however, it will allow people to connect to it, and it will allow the administrator, the one using the program, to perform certain moderation actions, like kicking a client, muting them, moving them to different areas, or making the server ignore their inputs, even denying them access to the server entirely if needs be.

Now obviously, unless I am wrong, I have to use a Winsock or similar protocol.

But beyond making a skeleton for the program interface and knowing I have to use a net-protocol, I am a bit confused. Because if I use such a thing, then people would have to use the program itself that I am making, wouldn't they?

I.e : I'm not trying to make a chat server client so much as a chat server manager, if that makes any sense.

This is mainly for hobby work, so any help is appreciated.


Edit:

I realize I did not quite give a clear picture, so I'll ad some additional info.

I don't need to call the actual files for music, backgrounds and rooms. Ideally I will have these in a text file as lines that dictate to the client side to use x music file or y avatar files. I.E : None of this is locally store, only the text files for configuration are.

Further more, These clients and what they say Ideally will appear in a list box. ((I have three separate list boxes, one for the clients list, one for what they say and do as a log file, and one for whatever is said in a separate text chat that I am currently not too concerned with, ideally, clients connecting, what they say and do in either section is recorded in one log file.))

Optionally, I might like for the administrator to send messages directly from this program as well, not necessarily as an avatar, but that is optional for the time being.

VS 2012 auto correct words

$
0
0
hello,
i'm building an Html Editor, and, I need auto correct words from a txt file for Rich Text Box.
Example: i type "<h" then he will ask me if i want "<h1>" or "<h2>" in Combo Box.
I Tried to make it Alone it wasn't go so well and i tried to look in internet couldn't find what i want...
Thank to Helpers.

VS 2015 Print a document with all the data in the forum

$
0
0
Hi,
I have a text box, a label and two DataGridViews on my form.


I want to extract data from these components and print a document with proper formatting.
Like name on top, data from DataGridViews in two columns.

How do I achieve this? Can someone point me to a good guide?
The teachers in my college do not teach this kind of stuff.

Problem with a class item with arraylist in Listview

$
0
0
Hey Guys! Hi all!, I have a problem with my program!, Look! this is my class

Attachment 135139

I have a class with an arraylist and now this are the items class:

Name:  Sin título2.jpg
Views: 56
Size:  28.7 KB

I add the items class to the listview here:

Name:  Sin título3.jpg
Views: 49
Size:  28.5 KB

The problem is this:

This is the form with the items in the listview, the lisview contains 3 columns (Nombre,Valor,Fecha)

Name:  Sin título5.jpg
Views: 49
Size:  29.6 KB

This is the edit form:

Name:  Sin título4.jpg
Views: 48
Size:  25.8 KB

The first TextBox is the selecteditem.text
The 0 is the SelectedItems.SubItems.Text
The DataTimePicker is SelectedItems.SubItems(2).Text

This is the code to load data in the edit form

Name:  Sin título6.jpg
Views: 53
Size:  29.0 KB

THE PROBLEM IS!!:

HOW I LOAD THE ITEMS IN ARRAYLIST IN THE ITEM(PRESUPUESTO) TO THE LISTVIEW "INSUMOS DEL PRESUPUESTO" IN THE EDIT FORM?

PLEASE HELP ME!

SORRY FOR MY BAD ENGLISH! :D
Attached Images
     

GetFiles error

$
0
0
I'm trying to use

Dim Dir0 As DirectoryInfo = New DirectoryInfo("R:\")
Dim Files() as New FileInfo = Dir0.GetFiles("*.*", IO.SearchOption.AllDirectories)

However R:\ contains the directory "System Volume Information", and when the second statement executes I get the error message that "Access to the path 'R:\System Volume Information' is denied."

Is there some way to exclude this directory from the GetFiles command, or some other way to get around the problem?

Need to cut down size of string

$
0
0
I have a string that can be anywhere from 80 to 100 characters long. The only part of the string that I want use is between characters PN and PRN. The index of those characters are never the same, but the condition is always the same, the string field I need is between PN and PRN. I was trying to use the .substring method but I am not sure it will work for me.
Does anybody have any idea on how to do this?

Newbie uart question

$
0
0
Hi guys, I am messing around with a windows form application written in VB on visual studio 2010.
I was using the numeric up down to generate a floating point number with one decimal place. I wanted to transmit this over serial when my button apply was clicked. is the numeric updown a good candidate for doing this as Id rater transmit a float over UART to a microcontroller than use ASCII.
Also If I have an application with two numeric updown boxes and i want to distinguish between them is it a good idea to say transmit a single char such as 'A' right before transmitting the contents of the numeric updown box? so it would be serial.write('a') then followed by the serial command to send the contents of the updown box?
thanks guys

Calculate the percentage of all numbers in a datagridview column

$
0
0
Hello,

Is it possible to calculate the percentage of the numbers in a column of a datagridview.

The min of max or averige of a column is no problem but the percentage ?

VS 2013 Start Program At Startup With Registry

$
0
0
I am currently trying to get my program to start up at Windows Startup. However, every code I create or find, I get errors thrown at me. I can't seem to get this to work no matter how many times I change my codes. Could someone please help me?

Here is my code:

Code:

Imports Microsoft.Win32
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim regkey As Microsoft.Win32.RegistryKey
        Dim Keyname As String = "SOFTWARE\Microsoft\Windows*\CurrentVersion\Run" 'Registrypath
        Dim ValueName As String = Application.ProductName 'Program name
        Dim Value As String = Application.ExecutablePath
        'Create Startup
        regkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(Keyname, True)
        regkey.SetValue(ValueName, Value, RegistryValueKind.String)
    End Sub
End Class


Here is the error that is thrown at me every time I try to run the function:
An unhandled exception of type 'System.NullReferenceException' occurred in WindowsApplication3.exe

Additional information: Object reference not set to an instance of an object.


How can I fix this? I know this should have been easy and fairly simple to do. I've been trying to work just this one function for hours. Any help would be greatly appreciated!

iPhone to PC via TCP

$
0
0
Hi. I wanted to create a bot on my PC that I can communicate with via my iPhone. I installed TCP Console on my iPhone and used some code I got from the internet to make a vb.NET program.

This is the code
Code:

Option Explicit On
Imports System.IO
Imports System.Net.Sockets

Public Class Form1
    Dim Listener As New TcpListener(8000)
    Dim Client As TcpClient

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
        Listener.Start()
    End Sub

    Private Sub _FormClosing() Handles Me.FormClosing
        Listener.Stop()
    End Sub

    Private Sub _Tick() Handles Timer1.Tick
        Dim Message As String
        If Listener.Pending = True Then
            Message = ""
            Client = Listener.AcceptTcpClient()
            Dim Reader As New StreamReader(Client.GetStream())

            While Reader.Peek > -1
                Message &= Convert.ToChar(Reader.Read()).ToString
            End While

            rtf.Text += Message + vbCrLf
        End If
    End Sub

    Private Sub btnSend_Click(ByVal sender As System.Object,  ByVal e As System.EventArgs) Handles btnSend.Click
        If txtSend.Text = "" Then Exit Sub
        Try
            Client = New TcpClient("192.168.1.67", 8000)
            Dim Writer As New StreamWriter(Client.GetStream())
            Writer.Write("BOT: " & txtSend.Text)
            Writer.Flush()
            rtf.Text += ("BOT: " & txtSend.Text) + vbCrLf
            txtSend.Text = ""
        Catch ex As Exception
            Console.WriteLine(ex)
            Dim Errorresult As String = ex.Message
            MessageBox.Show(Errorresult & vbCrLf & vbCrLf & _
                            "Please Review Client Address", _
                            "Error Sending Message", _
                            MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
End Class

The program can receive one line from the iPhone, but then stops receiving, and the iPhone doesn't receive any messages I send back. I used to use the winsock control in VB6, but I am clueless when it comes to doing the same thing in vb.NET.

Any ideas?
Viewing all 27206 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>