vb.net行號(hào) vb中行號(hào)是什么

vb.net中的問題

Message="未將對(duì)象引用設(shè)置到對(duì)象的實(shí)例。"

創(chuàng)新互聯(lián)主要從事成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)清流,10多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18980820575

Source="掃雷"

StackTrace:

在 WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs e) 位置 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\掃雷\掃雷\Form1.vb:行號(hào) 21

在 System.EventHandler.Invoke(Object sender, EventArgs e)

在 System.Windows.Forms.Form.OnLoad(EventArgs e)

在 System.Windows.Forms.Form.OnCreateControl()

在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

在 System.Windows.Forms.Control.CreateControl()

在 System.Windows.Forms.Control.WmShowWindow(Message m)

在 System.Windows.Forms.Control.WndProc(Message m)

在 System.Windows.Forms.ScrollableControl.WndProc(Message m)

在 System.Windows.Forms.ContainerControl.WndProc(Message m)

在 System.Windows.Forms.Form.WmShowWindow(Message m)

在 System.Windows.Forms.Form.WndProc(Message m)

在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message m)

在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message m)

在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

在 System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)

在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)

在 System.Windows.Forms.Form.SetVisibleCore(Boolean value)

在 System.Windows.Forms.Control.set_Visible(Boolean value)

在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

在 System.Windows.Forms.Application.Run(ApplicationContext context)

在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()

在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()

在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)

在 WindowsApplication1.My.MyApplication.Main(String[] Args) 位置 17d14f5c-a337-4978-8281-53493378c1071.vb:行號(hào) 81

在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)

在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)

在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

在 System.Threading.ThreadHelper.ThreadStart()

VB.NET中,如何獲得文本框中可見區(qū)域的首行的行號(hào)?

通過向文本框傳遞EM_LINEFROMCHAR消息可以得到光標(biāo)所在的行號(hào):

contst

EM_LINEFROMCHAR

=

0xC9

Dim

I

as

Long

I

=

SendMessage(textBox1.Hwnd,

EM_LINEFROMCHAR,

-1,

0)

VB.net怎么顯示RichTextBox的行數(shù)、列數(shù)和總行數(shù)啊?

求行:

RichTextBox1.GetLineFromChar(RichTextBox1.SelStart)+1

這個(gè)代碼呢,我的理解呢,是獲取在selstart的地方的行數(shù)。一般來講selstart的地方都是光標(biāo)的地方,然后會(huì)給你返回line。不過返回的時(shí)候要自己加1。不是很懂這個(gè)語法,有懂得可以教我一下

以上是求行數(shù)。

求列:

For i = 0 To RichTextBox1.SelStart

If RichTextBox1.GetLineFromChar(RichTextBox1.SelStart) - RichTextBox1.GetLineFromChar(RichTextBox1.SelStart - i) 0 Then Exit For

j = j + 1

Next i

這個(gè)for循環(huán)呢,講的是檢查這一行光標(biāo)前有多少個(gè)列,然后用J輸出列的個(gè)數(shù)。

因?yàn)閂B6.0沒有RichTextBox1.GetFirstCharIndexOfCurrentLine這種語法。所以就得自己模擬這個(gè)過程。

具體怎么檢查的呢,首先將 i 從0循環(huán)到光標(biāo)處,

如果 【光標(biāo)字符數(shù)】處的行數(shù) 減去 【光標(biāo)字符數(shù)減去 i 個(gè)字符數(shù)】處的行數(shù)小于0了,我寫了個(gè)不為零。但此時(shí)寫小于零就可以。那么代表著換行了,同時(shí)也代表著光標(biāo)到上一行之間有多少字。用j存儲(chǔ)循環(huán)次數(shù),得出對(duì)應(yīng)列數(shù)。(我們中文習(xí)慣是叫第一列,但程序?qū)嶋H上是第零列,但在循環(huán)的時(shí)候就注意到并解決這個(gè)問題了)

如果你替換寫法,例如

If RichTextBox1.GetLineFromChar(RichTextBox1.SelStart) - RichTextBox1.GetLineFromChar(RichTextBox1.SelStart + i) 0 Then Exit For

j = j + 1

Next i

這個(gè) J 就對(duì)應(yīng)著光標(biāo)到該行結(jié)尾有幾個(gè)字符了,如果有需要可以使用,但一般不需要。

那么就像上面說的那樣,行列都求出來了,最后用事件和TEXT或者caption表現(xiàn)出來就好了

至于說總行數(shù)

RichTextBox1.GetLineFromChar(Len(RichTextBox1.Text)) + 1

通過對(duì)最后一個(gè)字符的位置(總長(zhǎng)度)的行來判斷唄,不過也得加一。

本文名稱:vb.net行號(hào) vb中行號(hào)是什么
分享網(wǎng)址:http://muchs.cn/article6/hjcgog.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣、Google、動(dòng)態(tài)網(wǎng)站、商城網(wǎng)站企業(yè)建站、網(wǎng)頁設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)